Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions trees/avltree/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func (tree *Tree[K, V]) Iterator() *Iterator[K, V] {
return &Iterator[K, V]{tree: tree, node: nil, position: begin}
}

// IteratorAt returns a stateful iterator whose elements are key/value pairs that is initialised at a particular node.
func (tree *Tree[K, V]) IteratorAt(node *Node[K, V]) *Iterator[K, V] {
return &Iterator[K, V]{tree: tree, node: node, position: between}
}

// Next moves the iterator to the next element and returns true if there was a next element in the container.
// If Next() returns true, then next element's key and value can be retrieved by Key() and Value().
// If Next() was called for the first time, then it will point the iterator to the first element if it exists.
Expand Down