Ejemplo n.º 1
0
        public void Reset()
        {
            while (_currentMember.GetPrev() != null)
            {
                _currentMember = _currentMember.GetPrev();
            }

            _nextMember    = _currentMember;
            _currentMember = null;
        }
Ejemplo n.º 2
0
        public void Remove(int index)
        {
            if (index < 0 || index >= _size)
            {
                throw new IndexOutOfRangeException();
            }

            LinkedListMember targetMember = GetMember(index);

            LinkedListMember prev = targetMember.GetPrev();
            LinkedListMember next = targetMember.GetNext();

            prev?.SetNext(next);
            next?.SetPrev(prev);

            if (index == 0)
            {
                _first = next;
            }

            _size--;
        }
Ejemplo n.º 3
0
        public void Reverse()
        {
            if (_size < 2)
            {
                return;
            }

            LinkedListMember currentMember = _first;
            LinkedListMember newFirst      = null;

            while (currentMember != null)
            {
                LinkedListMember next = currentMember.GetNext();
                currentMember.SetNext(currentMember.GetPrev());
                currentMember.SetPrev(next);

                newFirst      = currentMember;
                currentMember = next;
            }

            _first = newFirst;
        }