Пример #1
0
        public bool FindPreviousKey(List <NodeIdxPair> stack)
        {
            int idx = stack.Count - 1;

            while (idx >= 0)
            {
                var pair = stack[idx];
                if (pair.Idx > 0)
                {
                    stack.RemoveRange(idx + 1, stack.Count - idx - 1);
                    stack[idx] = new NodeIdxPair {
                        Node = pair.Node, Idx = pair.Idx - 1
                    };
                    pair.Node.FillStackByRightMost(stack, pair.Idx - 1);
                    return(true);
                }
                idx--;
            }
            return(false);
        }
Пример #2
0
 public bool FindPreviousKey(List<NodeIdxPair> stack)
 {
     int idx = stack.Count - 1;
     while (idx >= 0)
     {
         var pair = stack[idx];
         if (pair.Idx > 0)
         {
             stack.RemoveRange(idx + 1, stack.Count - idx - 1);
             stack[idx] = new NodeIdxPair { Node = pair.Node, Idx = pair.Idx - 1 };
             pair.Node.FillStackByRightMost(stack, pair.Idx - 1);
             return true;
         }
         idx--;
     }
     return false;
 }
Пример #3
0
 public bool FindNextKey(List<NodeIdxPair> stack)
 {
     int idx = stack.Count - 1;
     while (idx >= 0)
     {
         var pair = stack[idx];
         if (pair.Node.NextIdxValid(pair.Idx))
         {
             stack.RemoveRange(idx + 1, stack.Count - idx - 1);
             stack[idx] = new NodeIdxPair { Node = pair.Node, Idx = pair.Idx + 1 };
             pair.Node.FillStackByLeftMost(stack, pair.Idx + 1);
             return true;
         }
         idx--;
     }
     return false;
 }