Exemple #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);
        }
Exemple #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;
            }
        }
Exemple #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);
 }
Exemple #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;
        }
Exemple #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;
 }
Exemple #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;
 }
Exemple #7
0
 /// <summary>
 /// Sets the right child fo the current SGLNode.
 /// </summary>
 /// <param name="SGLNode"></param>
 public void SetRight(SGLNode <T> SGLNode)
 {
     Next = SGLNode;
 }
Exemple #8
0
 /// <summary>
 /// Sets the left child of the current SGLNode.
 /// </summary>
 /// <param name="SGLNode"></param>
 public void SetLeft(SGLNode <T> SGLNode)
 {
     Previous = SGLNode;
 }
Exemple #9
0
 public SGLStack(T data)
 {
     Top = new SGLNode <T>(data);
 }
Exemple #10
0
 public SGLBinarySearchTree(T data, int identifier)
 {
     Root = new SGLNode <T>(data, identifier);
     Size++;
 }
Exemple #11
0
 public SGLLinkedList(SGLNode <T> node)
 {
     Head = node;
     Tail = node;
 }
Exemple #12
0
 public SGLQueue(T data)
 {
     Front = new SGLNode <T>(data);
 }
Exemple #13
0
 public SGLGraph(SGLNode <T> SGLNode, bool directed)
 {
     Directed = directed;
     Vertices = new SGLArrayList <SGLNode <T> >();
     Vertices.Add(SGLNode);
 }
Exemple #14
0
 public SGLGraph(SGLNode <T> SGLNode)
 {
     Directed = false;
     Vertices = new SGLArrayList <SGLNode <T> >();
     Vertices.Add(SGLNode);
 }
Exemple #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);
        }
Exemple #16
0
 public SGLLinkedList(SGLNode <T> head, SGLNode <T> tail)
 {
     Head = head;
     Tail = tail;
 }
Exemple #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);
        }
Exemple #18
0
 public SGLBinarySearchTree()
 {
     Root = null;
 }