示例#1
0
        public void InsertAfter(T target, T data)
        {
            var current = Head;

            while (current != null)
            {
                if (current.Data.Equals(target))
                {
                    var item = new DuplexItem <T>(data);
                    current.Next  = item.Next;
                    item.Next     = Tail;
                    Tail.Previous = item.Previous;

                    current.Next = item;
                    Count++;

                    Count++;
                    return;
                }
                else
                {
                    current = current.Next;
                }
            }
        }
示例#2
0
        public DuplexLinkedList(T data)
        {
            var item = new DuplexItem <T>(data);

            Head  = item;
            Tail  = item;
            Count = 1;
        }
示例#3
0
        public void Add(T data)
        {
            var item = new DuplexItem <T>(data);

            if (Count == 0)
            {
                Head  = item;
                Tail  = item;
                Count = 1;
                return;
            }
            Tail.Next     = item;
            item.Previous = Tail;
            Tail          = item;
            Count++;
        }