using System.Collections;
using System.Collections.Generic;
using GeoAPI.Geometries;
namespace GisSharpBlog.NetTopologySuite.Planargraph
{
///
/// A map of nodes, indexed by the coordinate of the node.
///
public class NodeMap
{
private readonly IDictionary nodeMap = new Dictionary();
///
/// Returns the Nodes in this NodeMap, sorted in ascending order
/// by angle with the positive x-axis.
///
public ICollection Values
{
get
{
return nodeMap.Values;
}
}
///
/// Returns the number of Nodes in this NodeMap.
///
public int Count
{
get
{
return nodeMap.Count;
}
}
///
/// Adds a node to the map, replacing any that is already at that location.
///
///
/// The added node.
public Node Add(Node n)
{
nodeMap[n.Coordinate] = n;
return n;
}
///
/// Removes the Node at the given location, and returns it (or null if no Node was there).
///
///
///
public Node Remove(ICoordinate pt)
{
Node node = (Node) nodeMap[pt];
nodeMap.Remove(pt);
return node;
}
///
/// Returns the Node at the given location, or null if no Node was there.
///
///
///
public Node Find(ICoordinate coord)
{
return (Node) nodeMap[coord];
}
///
/// Returns an Iterator over the Nodes in this NodeMap, sorted in ascending order
/// by angle with the positive x-axis.
///
public IEnumerator GetEnumerator()
{
return nodeMap.Values.GetEnumerator();
}
}
}