Beispiel #1
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);
        }
Beispiel #2
0
        public void Add(DoubleList data)
        {
            var node = new DoublyNode <DoubleList>(data);

            if (head == null)
            {
                head = node;
            }
            else
            {
                tail.Next     = node;
                node.Previous = tail;
            }
            tail = node;
            count++;
        }
Beispiel #3
0
        public void AddFirst(DoubleList data)
        {
            var node = new DoublyNode <DoubleList>(data);
            DoublyNode <DoubleList> temp = head;

            node.Next = temp;
            head      = node;
            if (count == 0)
            {
                tail = head;
            }
            else
            {
                temp.Previous = node;
            }
            count++;
        }
Beispiel #4
0
 public void Clear()
 {
     head  = null;
     tail  = null;
     count = 0;
 }