~ubuntu-branches/ubuntu/natty/jts/natty

« back to all changes in this revision

Viewing changes to src/com/vividsolutions/jts/planargraph/NodeMap.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2005-08-07 14:12:35 UTC
  • Revision ID: james.westby@ubuntu.com-20050807141235-7hy3ll3xpq79djcb
Tags: upstream-1.6
ImportĀ upstreamĀ versionĀ 1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
5
 *
 
6
 * Copyright (C) 2001 Vivid Solutions
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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
 
21
 *
 
22
 * For more information, contact:
 
23
 *
 
24
 *     Vivid Solutions
 
25
 *     Suite #1A
 
26
 *     2328 Government Street
 
27
 *     Victoria BC  V8T 5G5
 
28
 *     Canada
 
29
 *
 
30
 *     (250)385-6040
 
31
 *     www.vividsolutions.com
 
32
 */
 
33
 
 
34
package com.vividsolutions.jts.planargraph;
 
35
 
 
36
 
 
37
import java.util.Collection;
 
38
import java.util.Iterator;
 
39
import java.util.Map;
 
40
import java.util.TreeMap;
 
41
 
 
42
import com.vividsolutions.jts.geom.Coordinate;
 
43
 
 
44
/**
 
45
 * A map of {@link Node}s, indexed by the coordinate of the node.
 
46
 *
 
47
 * @version 1.6
 
48
 */
 
49
public class NodeMap
 
50
 
 
51
{
 
52
 
 
53
  private Map nodeMap = new TreeMap();
 
54
  
 
55
  /**
 
56
   * Constructs a NodeMap without any Nodes.
 
57
   */
 
58
  public NodeMap() {
 
59
  }
 
60
 
 
61
  /**
 
62
   * Adds a node to the map, replacing any that is already at that location.
 
63
   * @return the added node
 
64
   */
 
65
  public Node add(Node n)
 
66
  {
 
67
    nodeMap.put(n.getCoordinate(), n);
 
68
    return n;
 
69
  }
 
70
 
 
71
  /**
 
72
   * Removes the Node at the given location, and returns it (or null if no Node was there).
 
73
   */
 
74
  public Node remove(Coordinate pt)
 
75
  {
 
76
    return (Node) nodeMap.remove(pt);
 
77
  }
 
78
 
 
79
  /**
 
80
   * Returns the Node at the given location, or null if no Node was there.
 
81
   */
 
82
  public Node find(Coordinate coord)  {    return (Node) nodeMap.get(coord);  }
 
83
 
 
84
  /**
 
85
   * Returns an Iterator over the Nodes in this NodeMap, sorted in ascending order
 
86
   * by angle with the positive x-axis.
 
87
   */
 
88
  public Iterator iterator()
 
89
  {
 
90
    return nodeMap.values().iterator();
 
91
  }
 
92
  /**
 
93
   * Returns the Nodes in this NodeMap, sorted in ascending order
 
94
   * by angle with the positive x-axis.
 
95
   */
 
96
  public Collection values()
 
97
  {
 
98
    return nodeMap.values();
 
99
  }
 
100
 
 
101
}