java - How can I fetch data from Map -



java - How can I fetch data from Map<Point2D,Float> -

i'm beginner in java. here question: how can aggregate points map<point2d, float> relative float value (z-axis) ?

here how create map:

class="lang-java prettyprint-override">map<point2d, float> coordinates = new hashmap<point2d, float>();

i want point2d (x,y) on float z-coord. (z-axis)

for illustration

class="lang-none prettyprint-override"><(x=1,y=2),z=3> <(x=2,y=2),z=3> <(x=5,y=6),z=3> <(x=5,y=2),z=4>

and want points z=3 should 1,2,3rd , save in arraylist.

if can't alter info structure, you'll need iterate through map , take entrysets need;

for (map.entry<point2d, float> coordinatefloat: coordinates.entryset()) { point2d point = coordinatefloat.getkey(); float z = coordinatefloat.getvalue(); // ... can test z, , add together points other list. }

since you're operating on 2d points on each xy plane z=z, store info in way;

map<float, arraylist<point2d> > coordinates = new hashmap<float, arraylist<point2d> >();

this way, can iterate through xy planes, , convex hull algorithms on point collections;

for(map.entry<float, arraylist<point2d>> coordinatesonplane : coordinates.entryset()){ float z = coordinatesonplane.getkey(); for(point2d point : coordinatesonplane.getvalue()){ //... deed on points, or whatever. } }

java map

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -