Exemplo n.º 1
0
        public void Move()
        {
            var endOfSection  = _current;
            var steps         = 3;
            var sectionValues = new int[steps];

            while (steps-- > 0)
            {
                endOfSection         = endOfSection.Next;
                sectionValues[steps] = endOfSection.Item;
            }

            var start = _current.Next;

            _current.Next = endOfSection.Next;

            var itemToInsertNextTo = FindDestination(_current.Item, _min, _max, sectionValues);
            var itemAfterInsertion = itemToInsertNextTo.Next;

            endOfSection.Next       = itemAfterInsertion;
            itemToInsertNextTo.Next = start;

            _current = _current.Next;
        }