Exemplo n.º 1
0
        public IEnumerable <DoubleList> BackEnumerator()
        {
            DoublyNode <DoubleList> current = tail;

            while (current != null)
            {
                yield return(current.Data);

                current = current.Previous;
            }
        }
Exemplo n.º 2
0
        IEnumerator <DoubleList> IEnumerable <DoubleList> .GetEnumerator()
        {
            DoublyNode <DoubleList> current = head;

            while (current != null)
            {
                yield return(current.Data);

                current = current.Next;
            }
        }
Exemplo n.º 3
0
        public bool Contains(DoubleList data)
        {
            DoublyNode <DoubleList> current = head;

            while (current != null)
            {
                if (current.Data.Equals(data))
                {
                    return(true);
                }
                current = current.Next;
            }
            return(false);
        }
Exemplo n.º 4
0
        public void Add(DoubleList data)
        {
            DoublyNode <DoubleList> node = new DoublyNode <DoubleList>(data);

            if (head == null)
            {
                head = node;
            }
            else
            {
                tail.Next     = node;
                node.Previous = tail;
            }
            tail = node;
            count++;
        }
Exemplo n.º 5
0
        public void AddFirst(DoubleList data)
        {
            DoublyNode <DoubleList> node = new DoublyNode <DoubleList>(data);
            DoublyNode <DoubleList> temp = head;

            node.Next = temp;
            head      = node;
            if (count == 0)
            {
                tail = head;
            }
            else
            {
                temp.Previous = node;
            }
            count++;
        }
Exemplo n.º 6
0
 public void Clear()
 {
     head  = null;
     tail  = null;
     count = 0;
 }