adjacencylist.cs

来自「This is a document about routing [a spat」· CS 代码 · 共 52 行

CS
52
字号
using System;
using System.Collections;


namespace MapService
{
	/// <summary>
	/// AdjacencyList maintains a list of neighbors for a particular <see cref="Node"/>.  It is derived from CollectionBase
	/// and provides a strongly-typed collection of <see cref="EdgeToNeighbor"/> instances.
	/// </summary>
	public class AdjacencyList : CollectionBase
	{
		/// <summary>
		/// Adds a new <see cref="EdgeToNeighbor"/> instance to the AdjacencyList.
		/// </summary>
		/// <param name="e">The <see cref="EdgeToNeighbor"/> instance to add.</param>
		public virtual void Add(EdgeToNeighbor e)
		{
			base.InnerList.Add(e);
		}

        public virtual void Remove(EdgeToNeighbor e)
        {
            base.InnerList.Remove(e);
        }

        public virtual void Remove(Node e)
        {
            int i= InnerList.Count;
            while (i > 0)
            {
                i--;
                EdgeToNeighbor edge = (EdgeToNeighbor)InnerList[i];
                if (edge.Neighbor == e)
                    base.InnerList.Remove(edge);
                
            }
        }

		/// <summary>
		/// Returns a particular <see cref="EdgeToNeighbor"/> instance by index.
		/// </summary>
		public virtual EdgeToNeighbor this[int index]
		{
			get { return (EdgeToNeighbor) base.InnerList[index]; }
			set { base.InnerList[index] = value; }
		}


	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?