Processing Forum
- public void rebuildIndex() {
- // Creates a new container same type & size of vertices
- LinkedHashMap<Vec3D, Vertex> newV = new LinkedHashMap<Vec3D, Vertex>(vertices.size());
- // Loop through and assign its values to the previously created container
- for (Vertex v : vertices.values()) {
- newV.put(v, v);
- }
- // Assigns the duplicate container to the original
- vertices = newV;
- // Same process applies for the edges
- LinkedHashMap<Line3D, WingedEdge> newE = new LinkedHashMap<Line3D, WingedEdge>(edges.size());
- for (WingedEdge e : edges.values()) {
- newE.put(e, e);
- }
- edges = newE;
- }
A LinkedHashMap allows insertion-order iteration over the map. That is, when iterating a LinkedHashMap , the elements will be returned in the order in which they were inserted. More here.