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); }
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; }
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; }