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