Example #1
0
        private string StringForm(string data)
        {
            SGLArrayList <SGLNode <T> > SGLNodes = new SGLArrayList <SGLNode <T> >();
            SGLNode <T> temp  = Front;
            int         index = 0;

            while (temp != null)
            {
                SGLNodes.Add(temp);
                temp = temp.GetNext();
                data = data + SGLNodes.Get(index).ToString() + (temp == null ? "" : ", ");
                index++;
            }
            Front = SGLNodes.Get(0);
            return(data);
        }
Example #2
0
        public void AppendToTail(T data)
        {
            SGLNode <T> node = new SGLNode <T>(data);

            if (Head == null || Tail == null)
            {
                Head = node;
                Tail = node;
            }
            else
            {
                Tail.SetNext(node);
                node.SetPrevious(Tail);
                Tail = node;
            }
        }
Example #3
0
 /// <summary>
 /// Deletes a SGLNode by removing all references from the colection
 /// of vertices of the graph and its Nodes.
 /// </summary>
 /// <param name="SGLNode"></param>
 /// <returns></returns>
 public bool DeleteVertex(SGLNode <T> SGLNode)
 {
     Console.WriteLine(SGLNode.ToString() + " is the SGLNode");
     for (int i = 0; i < Vertices.Length(); i++)
     {
         for (int j = 0; j < Vertices.Get(i).GetAdjacencyList().Length(); j++)
         {
             if (Object.ReferenceEquals(Vertices.Get(i).GetAdjacencyList().Get(j), SGLNode))
             {
                 Vertices.Get(i).DeleteNode(SGLNode);
                 return(true);
             }
         }
     }
     return(false);
 }
Example #4
0
        /// <summary>
        /// Used to add an element ot the next most position of the Queue.
        /// </summary>
        /// <param name="data"></param>
        public void Enqueue(T data)
        {
            SGLNode <T> SGLNode = new SGLNode <T>(data);

            if (Front == null || Back == null)
            {
                Front = SGLNode;
                //Front.SetNext(Back);
                Back = SGLNode;
            }
            else
            {
                Back.SetNext(SGLNode);
                Back = SGLNode;
            }
            Size = Size + 1;
        }
Example #5
0
 /// <summary>
 /// Set the value of the previous SGLNode relative to the current SGLNode.
 /// </summary>
 /// <param name="data"></param>
 public void SetPrevious(SGLNode <T> data)
 {
     Previous = data;
 }
Example #6
0
 /// <summary>
 /// Sets the next SGLNode relative to the current SGLNode.
 /// </summary>
 /// <param name="data"></param>
 public void SetNext(SGLNode <T> data)
 {
     Next = data;
 }
Example #7
0
 /// <summary>
 /// Sets the right child fo the current SGLNode.
 /// </summary>
 /// <param name="SGLNode"></param>
 public void SetRight(SGLNode <T> SGLNode)
 {
     Next = SGLNode;
 }
Example #8
0
 /// <summary>
 /// Sets the left child of the current SGLNode.
 /// </summary>
 /// <param name="SGLNode"></param>
 public void SetLeft(SGLNode <T> SGLNode)
 {
     Previous = SGLNode;
 }
Example #9
0
 public SGLStack(T data)
 {
     Top = new SGLNode <T>(data);
 }
Example #10
0
 public SGLBinarySearchTree(T data, int identifier)
 {
     Root = new SGLNode <T>(data, identifier);
     Size++;
 }
Example #11
0
 public SGLLinkedList(SGLNode <T> node)
 {
     Head = node;
     Tail = node;
 }
Example #12
0
 public SGLQueue(T data)
 {
     Front = new SGLNode <T>(data);
 }
Example #13
0
 public SGLGraph(SGLNode <T> SGLNode, bool directed)
 {
     Directed = directed;
     Vertices = new SGLArrayList <SGLNode <T> >();
     Vertices.Add(SGLNode);
 }
Example #14
0
 public SGLGraph(SGLNode <T> SGLNode)
 {
     Directed = false;
     Vertices = new SGLArrayList <SGLNode <T> >();
     Vertices.Add(SGLNode);
 }
Example #15
0
        /// <summary>
        /// Adds an SGLNode to the list of associated SGLNodes.
        /// </summary>
        /// <param name="SGLNode"></param>
        public void AddNode(SGLNode <T> SGLNode)
        {
            SGLEdge <T> edge = new SGLEdge <T>(this, SGLNode);

            AdjacencyList.Add(edge);
        }
Example #16
0
 public SGLLinkedList(SGLNode <T> head, SGLNode <T> tail)
 {
     Head = head;
     Tail = tail;
 }
Example #17
0
        /// <summary>
        /// Adds an SGLNode to the list of associated SGLNodes using a direction.
        /// </summary>
        /// <param name="SGLNode"></param>
        public void AddNode(SGLNode <T> SGLNode, bool isDirected)
        {
            SGLEdge <T> edge = new SGLEdge <T>(this, SGLNode, isDirected);

            AdjacencyList.Add(edge);
        }
Example #18
0
 public SGLBinarySearchTree()
 {
     Root = null;
 }