Exemplo n.º 1
0
        public IEnumerable <T> BackEnumerator()
        {
            DoubleNode <T> current = this.tail;

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

                current = current.Previous;
            }
        }
Exemplo n.º 2
0
        public IEnumerator <T> GetEnumerator()
        {
            DoubleNode <T> current = this.head;

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

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

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

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

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