Ejemplo n.º 1
0
        public override LinkedListNode <LinkedListItem> RunOnLinkedList(
            LinkedListExecutionState state)
        {
            LinkedListNode <LinkedListItem> successor = state.List.Last;

            while (successor.Previous != state.List.First &&
                   successor.Previous.Value.Deleted)
            {
                successor = successor.Previous;
            }
            return(state.AddingToKnownNodes(state.List.AddBefore(successor, new LinkedListItem(Value))));
        }
        public override LinkedListNode <LinkedListItem> RunOnLinkedList(
            LinkedListExecutionState state)
        {
            LinkedListNode <LinkedListItem> current = state.Current;

            if (current == null || current == state.List.Last)
            {
                return(null);
            }

            if (!current.Value.Deleted)
            {
                return(state.AddingToKnownNodes(
                           state.List.AddAfter(current, new LinkedListItem(Value))));
            }
            LinkedListNode <LinkedListItem> prev = current;

            while (prev.Previous.Value.Deleted)
            {
                prev = prev.Previous;
            }
            return(state.AddingToKnownNodes(state.List.AddBefore(prev, new LinkedListItem(Value))));
        }
        // ReSharper disable once RedundantAssignment
        public override LinkedListNode <LinkedListItem> RunOnLinkedList(
            LinkedListExecutionState state)
        {
            LinkedListNode <LinkedListItem> last = state.List.Last;

            do
            {
                last = last.Previous;
            }while (last != state.List.First && last.Value.Deleted);
            if (last == state.List.First)
            {
                return(null);
            }
            last.Value.Delete();
            return(state.AddingToKnownNodes(last));
        }
Ejemplo n.º 4
0
        RunOnLinkedList(
            LinkedListExecutionState state)
        {
            LinkedListNode <LinkedListItem> current = state.Current;

            if (current == null || current == state.List.First)
            {
                return(null);
            }
            LinkedListNode <LinkedListItem> successor = current;

            while (successor.Previous.Value.Deleted)
            {
                successor = successor.Previous;
            }
            return(state.AddingToKnownNodes(state.List.AddBefore(successor, new LinkedListItem(Value))));
        }
Ejemplo n.º 5
0
        public override LinkedListNode <LinkedListItem> RunOnLinkedList(LinkedListExecutionState state)
        {
            if (state.Current == null ||
                state.Current == state.List.Last ||
                state.Current == state.List.First)
            {
                return(null);
            }
            ListItemData oldData = state.Current.Value.Data;

            if (oldData.Value != prevalentValue ||
                state.Current.Value.Deleted)
            {
                state.AddToKnownNodes(null);
                return(null);
            }
            return
                (state.AddingToKnownNodes(
                     state.List.AddAfter(state.Current, new LinkedListItem(Value))));
        }
Ejemplo n.º 6
0
 public override LinkedListNode <LinkedListItem> RunOnLinkedList(
     LinkedListExecutionState state)
 {
     return(state.AddingToKnownNodes(
                state.List.AddAfter(state.List.First, new LinkedListItem(Value))));
 }