Пример #1
0
 public CustomList()
 {
     _head       = new CustomNode <TData>();
     _tail       = new CustomNode <TData>();
     _head.Next  = _tail;
     _tail.Prev  = _head;
     _enumerator = new Enumerator(this);
 }
Пример #2
0
 public bool MoveNext()
 {
     if (_current.Next == _list._tail)
     {
         return(false);
     }
     _current = _current.Next;
     return(true);
 }
Пример #3
0
        public CustomList <TData> InsertAfter(CustomNode <TData> after, TData val)
        {
            var node = new CustomNode <TData> {
                Value = val,
                Next  = after.Next,
                Prev  = after
            };

            after.Next.Prev = node;
            after.Next      = node;
            return(this);
        }
Пример #4
0
        public CustomList <TData> PushFront(TData val)
        {
            var node = new CustomNode <TData> {
                Value = val,
                Prev  = _head,
                Next  = _head.Next
            };

            _head.Next.Prev = node;
            _head.Next      = node;
            return(this);
        }
Пример #5
0
        public CustomList <TData> PushBack(TData val)
        {
            var node = new CustomNode <TData> {
                Value = val,
                Prev  = _tail.Prev,
                Next  = _tail
            };

            _tail.Prev.Next = node;
            _tail.Prev      = node;
            return(this);
        }
Пример #6
0
        public CustomList <TData> InsertBefore(CustomNode <TData> before, TData val)
        {
            var node = new CustomNode <TData> {
                Value = val,
                Next  = before,
                Prev  = before.Prev
            };

            before.Prev.Next = node;
            before.Prev      = node;
            return(this);
        }
Пример #7
0
 public void Reset()
 {
     _current = _list._head;
 }
Пример #8
0
 public Enumerator(CustomList <TData> list)
 {
     _list    = list;
     _current = list._head;
 }
Пример #9
0
 public CustomList <TData> RemoveBetween(CustomNode <TData> begin, CustomNode <TData> end)
 {
     begin.Next = end;
     end.Prev   = begin;
     return(this);
 }