Adding GetParent to SortedTree

This commit is contained in:
Jake Norbut committed 2019-04-04 07:50:26 -05:00
1 parent 1e55443415
commit aade53eaeb
1 file changed
+7
@@ -305,6 +305,13 @@ namespace bts.collections {
Node GetRootNode(Node node) =>
_index.TryGetValue(parent(node.value), out Node pnode) ? GetRootNode(pnode) : node;
public INode<T> GetParent(T item) {
if (_index.TryGetValue(parent(item), out Node pnode)) {
return pnode;
}
return null;
}
public IEnumerable<T> EnumerateGroup(T item) {
var pnode = parentmost(item);
return pnode == null ? Enumerable.Empty<T>() : EnumerateNode(pnode);