コード例 #1
0
        public void Remove(T val)
        {
            DynamicDoublyLinkedList <T> element = this.Search(val);

            if (element == null)
            {
                //throw exception
            }

            element.previous.next = element.next;
            element.next.previous = element.previous;
        }
コード例 #2
0
        public T[] GetArray()
        {
            int elementsCount = this.countElements();

            T[] arrayElements = new T[elementsCount];
            DynamicDoublyLinkedList <T> ptr = this;

            for (int i = 0; i < elementsCount; i++)
            {
                arrayElements[i] = ptr.val;
                ptr = ptr.next;
            }
            return(arrayElements);
        }
コード例 #3
0
        public void Add(T value)
        {
            DynamicDoublyLinkedList <T> toAdd = new DynamicDoublyLinkedList <T>(value);

            if (this.next == null)
            {
                this.next      = toAdd;
                toAdd.previous = this;
            }
            else
            {
                this.next.previous = toAdd;
                toAdd.next         = this.next;
                this.next          = toAdd;
                toAdd.previous     = this;
            }
        }
コード例 #4
0
 public DynamicDoublyLinkedList(T val)
 {
     this.next     = null;
     this.previous = null;
     this.val      = val;
 }