2
* The JTS Topology Suite is a collection of Java classes that
3
* implement the fundamental operations required to validate a given
4
* geo-spatial data set to a known topological specification.
6
* Copyright (C) 2001 Vivid Solutions
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* For more information, contact:
26
* 2328 Government Street
31
* www.vividsolutions.com
34
package com.vividsolutions.jts.planargraph;
37
import java.util.Collection;
38
import java.util.Iterator;
40
import java.util.TreeMap;
42
import com.vividsolutions.jts.geom.Coordinate;
45
* A map of {@link Node}s, indexed by the coordinate of the node.
53
private Map nodeMap = new TreeMap();
56
* Constructs a NodeMap without any Nodes.
62
* Adds a node to the map, replacing any that is already at that location.
63
* @return the added node
65
public Node add(Node n)
67
nodeMap.put(n.getCoordinate(), n);
72
* Removes the Node at the given location, and returns it (or null if no Node was there).
74
public Node remove(Coordinate pt)
76
return (Node) nodeMap.remove(pt);
80
* Returns the Node at the given location, or null if no Node was there.
82
public Node find(Coordinate coord) { return (Node) nodeMap.get(coord); }
85
* Returns an Iterator over the Nodes in this NodeMap, sorted in ascending order
86
* by angle with the positive x-axis.
88
public Iterator iterator()
90
return nodeMap.values().iterator();
93
* Returns the Nodes in this NodeMap, sorted in ascending order
94
* by angle with the positive x-axis.
96
public Collection values()
98
return nodeMap.values();