Last active
March 13, 2022 02:32
-
-
Save kinow/c590789efba00d4449eb1f5e5a7047ec to your computer and use it in GitHub Desktop.
GEOMETRY-142
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.commons.geometry.examples.tutorials; | |
import java.util.Map; | |
import org.apache.commons.geometry.core.collection.PointMap; | |
import org.apache.commons.geometry.core.internal.PointMapAsSetAdapter; | |
import org.apache.commons.geometry.euclidean.EuclideanCollections; | |
import org.apache.commons.geometry.euclidean.oned.Vector1D; | |
import org.apache.commons.numbers.core.Precision; | |
public class Testes { | |
public static void main(String[] args) { | |
Vector1D point = Vector1D.of(10d); | |
PointMap<Vector1D, Object> map = EuclideanCollections.pointMap1D(Precision.doubleEquivalenceOfEpsilon(0.01d)); | |
map.put(point, 1_000); | |
map.put(point, 10_000); // replaces previous entry, OK | |
PointMapAsSetAdapter<Vector1D, PointMap<Vector1D, Object>> fakeSet = | |
new PointMapAsSetAdapter<Vector1D, PointMap<Vector1D, Object>>(map); | |
{ | |
for (@SuppressWarnings("rawtypes") Map.Entry entry : map.entrySet()) { | |
System.out.println(entry.getKey() + "=>" + entry.getValue()); | |
} | |
System.out.println(fakeSet); | |
} | |
boolean b = fakeSet.remove(point); | |
System.out.println(b); | |
fakeSet.add(point); | |
{ | |
for (@SuppressWarnings("rawtypes") Map.Entry entry : map.entrySet()) { | |
System.out.println(entry.getKey() + "=>" + entry.getValue()); | |
} | |
System.out.println(fakeSet); | |
} | |
b = fakeSet.remove(point); | |
System.out.println(b); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment