Exemple #1
0
        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;
            }
        }
Exemple #2
0
        /// <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;
        }
Exemple #3
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;
            }
        }