diff --git a/ln.collections/BTree.cs b/ln.collections/BTree.cs index 0f5c2ba..ae613f2 100644 --- a/ln.collections/BTree.cs +++ b/ln.collections/BTree.cs @@ -303,6 +303,43 @@ namespace ln.collections return true; } + public bool TryGetNextOrCurrent(K current, out K nextOrCurrent) + { + if (Empty) + { + nextOrCurrent = default(K); + return false; + } + + TreeNode next = FindFirstGE(current); + if (next == null) + { + nextOrCurrent = default(K); + return false; + } + + nextOrCurrent = next.Key; + return true; + } + public bool TryGetNextOrCurrentValue(K current, out V nextOrCurrentValue) + { + if (Empty) + { + nextOrCurrentValue = default(V); + return false; + } + + TreeNode next = FindFirstGE(current); + if (next == null) + { + nextOrCurrentValue = default(V); + return false; + } + + nextOrCurrentValue = next.Value; + return true; + } + private TreeNode First(TreeNode node)