Exemple #1
0
            internal EdgeEnumerator(GraphAsLists graph)
            {
                v   = -1;
                ptr = null;

                this.graph = graph;
            }
Exemple #2
0
            public virtual bool MoveNext()
            {
                bool flag;

                if (ptr != null)
                {
                    ptr = ptr.Next;
                }
                if (ptr != null)
                {
                    flag = true;
                    return(flag);
                }

                for (v++; v < graph.mNumberOfVertices; v++)
                {
                    ptr = graph.adjacencyList[v].Head;
                    if (ptr == null)
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                v = -1;
                return(false);
            }
            /// <summary>
            /// Moves the pointer to the next element in the enumeration
            /// </summary>
            /// <returns></returns>
            public virtual bool MoveNext()
            {
                if (element != null)
                {
                    element = element.Next;
                }
                if (element == null)
                {
                    for (position++; position < hashtable.Length; position++)
                    {
                        element = hashtable.array[position].Head;
                        if (element != null)
                        {
                            break;
                        }
                    }
                    if (position == hashtable.Length)
                    {
                        position = -1;
                    }
                }
                bool flag = element == null == false;

                return(flag);
            }
            /// <summary>
            /// Internal constructor
            /// </summary>
            /// <param name="hashtable"></param>
            internal Enumerator(ChainedHashTable hashtable)
            {
                element  = null;
                position = -1;

                this.hashtable = hashtable;
            }
Exemple #5
0
            internal EmanatingEdgeEnumerator(GraphAsLists graph, int v)
            {
                ptr = null;

                this.graph = graph;
                this.v     = v;
            }
Exemple #6
0
 /// <summary>
 /// Accepts a visitor
 /// </summary>
 /// <param name="visitor"></param>
 public override void Accept(IVisitor visitor)
 {
     for (LinkedList.Element element = list.Head; element != null; element = element.Next)
     {
         visitor.Visit(element.Datum);
         if (visitor.IsDone)
         {
             break;
         }
     }
 }
Exemple #7
0
            public virtual bool MoveNext()
            {
                if (ptr == null)
                {
                    ptr = graph.adjacencyList[v].Head;
                }
                else
                {
                    ptr = ptr.Next;
                }

                return(ptr != null);
            }
Exemple #8
0
            public virtual bool MoveNext()
            {
                if (ptr == null)
                {
                    ptr = list.Head;
                }
                else
                {
                    ptr = ptr.Next;
                }

                return(ptr != null);
            }
Exemple #9
0
 /// <summary>
 /// Gets the edge between the given vertices
 /// </summary>
 /// <param name="v"></param>
 /// <param name="w"></param>
 /// <returns></returns>
 public override IEdge GetEdge(int v, int w)
 {
     Bounds.Check(v, 0, mNumberOfVertices);
     Bounds.Check(w, 0, mNumberOfVertices);
     for (LinkedList.Element element = adjacencyList[v].Head; element != null; element = element.Next)
     {
         IEdge edge1 = (IEdge)element.Datum;
         if (edge1.V1.Number == w)
         {
             return(edge1);
         }
     }
     throw new ArgumentException("edge not found");
 }
Exemple #10
0
            /// <summary>
            /// Moves the pointer to the next element, if any
            /// </summary>
            /// <returns>true if there is a next element</returns>
            public virtual bool MoveNext()
            {
                if (position == null)
                {
                    position = stack.list.Head;
                }
                else
                {
                    position = position.Next;
                }
                bool flag = position == null == false;

                return(flag);
            }
 /// <summary>
 /// Accepts an IVisitor
 /// </summary>
 /// <param name="visitor"></param>
 public override void Accept(IVisitor visitor)
 {
     for (int i = 0; i < this.Length; i++)
     {
         for (LinkedList.Element element = array[i].Head; element != null; element = element.Next)
         {
             visitor.Visit(element.Datum);
             if (visitor.IsDone)
             {
                 return;
             }
         }
     }
 }
Exemple #12
0
        /// <summary>
        /// Returns true if there is an edge between the given vertices
        /// </summary>
        /// <param name="v"></param>
        /// <param name="w"></param>
        /// <returns></returns>
        /// <remarks>Thanks to Morton Mertner again here</remarks>
        public override bool IsEdge(int v, int w)
        {
            bool isEdge = false;

            Bounds.Check(v, 0, mNumberOfVertices);
            Bounds.Check(w, 0, mNumberOfVertices);
            for (LinkedList.Element element = adjacencyList[v].Head; element != null; element = element.Next)
            {
                isEdge |= ((IEdge)element.Datum).V1.Number == w;
                if (isEdge)
                {
                    break;
                }
            }
            return(isEdge);
        }
        /// <summary>
        /// Searches the given object in the hashtable
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override ComparableObject Find(ComparableObject obj)
        {
            ComparableObject comparableObject2;

            for (LinkedList.Element element = array[base.H(obj)].Head; element != null; element = element.Next)
            {
                ComparableObject comparableObject1 = (ComparableObject)element.Datum;
                if (obj != comparableObject1)
                {
                    continue;
                }
                comparableObject2 = comparableObject1;
                return(comparableObject1);
            }
            comparableObject2 = null;
            return(comparableObject2);
        }
        /// <summary>
        /// Returns whether the given object is contained in the hashtable
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool IsMember(ComparableObject obj)
        {
            bool flag;

            for (LinkedList.Element element = array[base.H(obj)].Head; element != null; element = element.Next)
            {
                ComparableObject comparableObject = (ComparableObject)element.Datum;
                if (obj != comparableObject)
                {
                    continue;
                }
                flag = true;
                return(flag);
            }
            flag = false;
            return(flag);
        }
Exemple #15
0
            internal IncidentEdgeEnumerator(GraphAsLists graph, int v)
            {
                ptr = null;

                this.graph = graph;
                list       = new LinkedList();


                IEnumerator numer = graph.Edges.GetEnumerator();

                while (numer.MoveNext())
                {
                    IEdge edge = numer.Current as IEdge;
                    if (edge.V1.Number == v)
                    {
                        list.Append(edge);
                    }
                }

                this.v = v;
            }
Exemple #16
0
 public virtual void Reset()
 {
     v   = -1;
     ptr = null;
 }
 /// <summary>
 /// Resets the enumeration pointer
 /// </summary>
 public virtual void Reset()
 {
     element  = null;
     position = -1;
 }
Exemple #18
0
 /// <summary>
 /// Constructor, internal
 /// </summary>
 /// <param name="stack"></param>
 internal Enumerator(StackAsLinkedList stack)
 {
     position   = null;
     this.stack = stack;
 }
Exemple #19
0
 /// <summary>
 /// Resets the pointer to the beginning of the list
 /// </summary>
 public virtual void Reset()
 {
     position = null;
 }
Exemple #20
0
 public virtual void Reset()
 {
     ptr = null;
 }