예제 #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++;
        }