예제 #1
0
        public IEnumerable <T> BackEnumerator()
        {
            DoubleNode <T> current = this.tail;

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

                current = current.Previous;
            }
        }
예제 #2
0
        public IEnumerator <T> GetEnumerator()
        {
            DoubleNode <T> current = this.head;

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

                current = current.Next;
            }
        }
예제 #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);
        }
예제 #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++;
        }
예제 #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++;
        }
예제 #6
0
 public void Clear()
 {
     this.head  = null;
     this.tail  = null;
     this.count = 0;
 }