public TreeEnumerator(ITreeNodeManager <K, V> nodeManager, TreeNode <K, V> node, int startIndex, TreeScanDirections direction) { this.nodeManager = nodeManager; this.curNode = node; this.curIndex = startIndex; this.scanNext = ( direction == TreeScanDirections.Ascending ? new Func <bool>(Ascend) : new Func <bool>(Descend) ); }
public TreeScanner(ITreeNodeManager <K, V> nodeManager, TreeNode <K, V> node, int startIndex, TreeScanDirections direction) { if (nodeManager == null) { throw new ArgumentNullException("nodeManager"); } if (node == null) { throw new ArgumentNullException("node"); } this.nodeManager = nodeManager; this.node = node; this.startIndex = startIndex; this.direction = direction; }
/// <summary> /// Finds all entries with the keys matching or (larger if ascending, lesser if descending) to specified key. /// </summary> public IEnumerable <Tuple <K, V> > GetExactMatch(K key, bool ascending) { int index = 0; var node = FindNodeIterative(key, nodeManager.RootNode, ascending, ref index); TreeScanDirections scanDirection = TreeScanDirections.Ascending; if (ascending) { index = (index >= 0 ? index : ~index) - 1; } else { index = index >= 0 ? index + 1 : ~index; scanDirection = TreeScanDirections.Descending; } return(new TreeScanner <K, V>( nodeManager, node, index, scanDirection )); }