Skip to content

Instantly share code, notes, and snippets.

@kinow
Last active March 13, 2022 02:32
Show Gist options
  • Save kinow/c590789efba00d4449eb1f5e5a7047ec to your computer and use it in GitHub Desktop.
Save kinow/c590789efba00d4449eb1f5e5a7047ec to your computer and use it in GitHub Desktop.
GEOMETRY-142
Display the source blob
Display the rendered blob
Raw
{}
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);
{
// print
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);
{
// print
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