public void AppendToHead(T data) { SGLNode <T> node = new SGLNode <T>(data); if (Head == null || Tail == null) { Head = node; Tail = node; } else { Head.SetPrevious(node); node.SetNext(Head); Head = node; } }
/// <summary> /// Add an element to the top of the Stack. /// </summary> /// <param name="data"></param> public void Push(T data) { SGLNode <T> SGLNode = new SGLNode <T>(data); if (Top == null) { Top = SGLNode; } else { Top.SetPrevious(SGLNode); SGLNode.SetNext(Top); Top = SGLNode; } Size = Size + 1; }
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; } }