I'm trying to move items in my list but when I compare against the last option I exit out before I move the items in my move linked list. Is there a way to do that before the node gets put at the end and can't loop through to move the items?
LinkedList<BD> list = new LinkedList<BD>(b[arg].Values);
LinkedListNode<BD> node, terminator, next = null;
List<LinkedListNode<BD>> move = new List<LinkedListNode<BD>>();
terminator = list.First;
node = next = list.Last;
while (next != null && next != terminator)
{
node = next;
next = next.Previous;
if (IDs.Contains(node.Value.Id))
{
move.Add(node);
list.Remove(node);
}
else
{
foreach (var item in move)
{
list.AddBefore(node, item);
node = node.Previous;
}
move.Clear();
}
}