Exemplo n.º 1
0
            /// <summary>
            /// Creates new instance of BPlusTreeEnumerator type
            /// </summary>
            /// <param name="nodes">Node provider which contains tree nodes</param>
            /// <param name="rootNodeId">Root item ID</param>
            /// <param name="edgeType">Edge type to use as a filter for enumeration</param>
            public BPlusTreeEnumerator(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId, EdgeType edgeType)
            {
                this.nodes      = nodes;
                this.rootNodeId = rootNodeId;
                this.edgeType   = edgeType;
                var currentLeaf = BPlusTreeOperations.LeftLeaf(nodes, nodes.GetNode(rootNodeId, NodeAccess.Read));

                this.currentLeafEnumerator = currentLeaf.Edges.Values.GetEnumerator();
            }
Exemplo n.º 2
0
            /// <summary>
            /// Resets the enumerator
            /// </summary>
            public void Reset()
            {
                if (currentLeafEnumerator != null)
                {
                    currentLeafEnumerator.Dispose();
                }

                var currentLeaf = BPlusTreeOperations.LeftLeaf(nodes, nodes.GetNode(rootNodeId, NodeAccess.Read));

                this.currentLeafEnumerator = currentLeaf.Edges.Values.GetEnumerator();
            }
Exemplo n.º 3
0
            /// <summary>
            /// Moves to next item without regards to edge type
            /// </summary>
            /// <returns>True if next item was found</returns>
            private bool MoveNextInternal()
            {
                if (currentLeafEnumerator == null)
                {
                    return(false);
                }

                var current = Current;

                EdgeData sampleData = null;

                if (current != null)
                {
                    sampleData = current.Data;
                }

                bool res = currentLeafEnumerator.MoveNext();

                if (res)
                {
                    return(true);
                }
                else
                {
                    this.currentLeafEnumerator.Dispose();
                    this.currentLeafEnumerator = null;

                    var currentLeaf = BPlusTreeOperations.NextLeaf(nodes, rootNodeId, sampleData);

                    if (currentLeaf == null)
                    {
                        return(false);
                    }
                    else
                    {
                        this.currentLeafEnumerator = currentLeaf.Edges.Values.GetEnumerator();
                        return(currentLeafEnumerator.MoveNext());
                    }
                }
            }