Esempio n. 1
0
        public SimpleNode <T> Peak()
        {
            if (_head == null)
            {
                return(null);
            }

            SimpleNode <T> temp = _head;

            while (temp.HasNext())
            {
                temp = temp.GetNext();
            }
            return(temp);
        }
Esempio n. 2
0
        public void Append(T value)
        {
            if (_head == null)
            {
                _head = new SimpleNode <T>(value);
                return;
            }
            SimpleNode <T> temp = _head;

            while (temp.HasNext())
            {
                temp = temp.GetNext();
            }
            temp.SetNext(new SimpleNode <T>(value));
        }
Esempio n. 3
0
        public SimpleNode <T> Dequeue()
        {
            if (_head == null)
            {
                return(null);
            }

            SimpleNode <T> temp = _head;
            SimpleNode <T> prev = null;

            while (temp.HasNext())
            {
                prev = temp;
                temp = temp.GetNext();
            }
            if (prev == null)
            {
                Clear();
                return(temp);
            }
            prev.SetNext(null);
            return(temp);
        }