Added BTree.TryGetNextOrCurrent(), BTree.TryGetNextOrCurrentValue()
parent
aab19b5417
commit
7738a4028c
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue