示例#1
0
        private static void Skip(ref LinkedListContext <T> context, out Option <T> next)
        {
            context.bd.DetectBacktrack();

            if (context.needsMove)
            {
                var step = context.step;
                while (step > 0 && context.node != null)
                {
                    context.node = context.node.Next;
                    --step;
                }
                while (step < 0 && context.node != null)
                {
                    context.node = context.node.Previous;
                    ++step;
                }
            }
            else
            {
                context.needsMove = true;
            }


            if (context.node == null)
            {
                next = new Option <T>();
                context.bd.Release();
            }
            else
            {
                next = new Option <T>(context.node.Value);
            }
        }
示例#2
0
        private static void Remove(ref LinkedListContext <T> context, out Option <T> next)
        {
            context.bd.DetectBacktrack();

            if (context.step == 0)
            {
                next = new Option <T>();
                context.node.List.Remove(context.node);
                context.bd.Release();
            }
            else
            {
                var node = context.node;
                Skip(ref context, out next);
                node.List.Remove(node);
            }
        }
示例#3
0
 private static void DisposeNodes(ref LinkedListContext <T> context, out Option <LinkedListNode <T> > next)
 {
     next = new Option <LinkedListNode <T> >();
     context.bd.Release();
 }