Exemple #1
0
        public void AddAfter(T value)
        {
            DbNode <T> newNode = new DbNode <T>(value);

            if (head == null)
            {
                head = newNode;
            }
            else
            {
                DbNode <T> lastNode = this.GetNodeByIndex(this.Count - 1);
                lastNode.Next = newNode;
                newNode.Prev  = lastNode;
            }
            Count++;
        }
Exemple #2
0
        public void RemoveAt(int index)
        {
            if (index < 0 || index > this.Count - 1)
            {
                throw new ArgumentOutOfRangeException("index", "索引超出范围");
            }

            DbNode <T> deleteNode = this.GetNodeByIndex(index);

            DbNode <T> prevNode = deleteNode.Prev;
            DbNode <T> nextNode = deleteNode.Next;


            prevNode.Next = nextNode;
            nextNode.Prev = prevNode;

            Count--;
        }