Expand description
Seekable Iterator
§Traits
Provides:
SeekableIterator,SeekableLendingIterator, andSeekablePooledIteratortraits, for circular iterators that can move backwards or forwards and seek.PooledIteratortrait, for iterators that would normally be a lending iterator, but use a buffer pool to lend out multiple items at the same time.CursorIterator,CursorLendingIterator, andCursorPooledIteratortraits, for circular iterators that can move backwards or forwards by one element.Seekabletrait, with all the seeking methods required by theSeekable*Iteratortraits.Comparatortrait, for comparisons done to seek.LendItemandItemToKey: helper traits for lending iterators.
Adapters to lender::Lender and lending_iterator::LendingIterator are provided for
CursorLendingIterator and PooledIterator when the corresponding features are enabled.
Depending on features, MergingIter, PooledIter, and ThreadsafePooledIter iterator
adapters are provided.
§Semantics
The PooledIterator trait makes roughly the same semantic assumptions about the iterator as
a normal iterator.
However, the Cursor*Iterator and Seekable*Iterator traits assume that an implementor is a
circular iterator over some ordered collection; the iterator is made circular by adding a phantom
element before the first element and after the last element of the ordered collection. The iterator
is thus not a FusedIterator, as after iteration over the collection is completed, the iterator
wraps back around to the start.
The PooledIterator and Cursor*Iterator traits do not expose any comparator that the ordered
collection and iterator might be using, but the Seekable and Seekable*Iterator traits do
expose it via a Comparator generic. An OrdComparator struct is provided that can compare
keys that implement Ord, using their Ord implementation.
§Features
clone-behavior(enabled by default): Implementsclone-behaviortraits forOrdComparator.generic-container(enabled by default): ImplementsComparatorfor containers ofdyn Comparator, and forGenericContainerwheneverGenericContainerwraps a container of aComparatorimplementation.lender: provide adapters tolender::Lender.lending-iterator: provide adapters tolending_iterator::LendingIterator.alloc: provideMergingIter, which merges together severalSeekableLendingIterators into oneSeekableLendingIteratorthat iterates over all their items in order. Similar to adapters likeitertools’kmerge, though somewhat more complicated in order to support switching the direction of iteration. Note:allocisn’t truly crucial forMergingIter; open an issue if you want it on no-alloc.std: doesn’t do much alone. Enablesalloc, as well as thestdfeature of a dependency.anchored-pool: providePooledIterandThreadsafePooledIter.PooledIteris an adapter fromCursorLendingIteratortoCursorPooledIterator, andThreadsafePooledIteris aSend + Syncversion. This feature enablesstd, thoughstdisn’t truly crucial forPooledIter; open an issue if you want it on no-std with alloc.anchored-pool-default: same as above, and enable the default feature flags ofanchored-pool. Theanchored-poolcrate requires that either itskanalorcrossbeam-channelfeature is enabled; using theanchored-poolfeature flag alone will result in a compile-time error unless you enable thekanalorcrossbeam-channelflag yourself.
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Structs§
- Lender
Adapter lender - An adapter for
CursorLendingIteratorwhich implementslender::Lender. - Lending
Iterator Adapter lending-iterator - An adapter for
CursorLendingIteratorwhich implementslending_iterator::LendingIterator. - Merging
Iter alloc - A
MergingItertakes severalSeekableLendingIterators as input, and iterates over the sorted union of their entries. - OrdComparator
- A
Comparatorwhich uses keys’Ordimplementations. - OutOf
Buffers - An error that may be returned if no buffer pools were available in a
PooledIterator, instead of waiting for a buffer to become available. - Pool
Item anchored-pool - The type of an item returned by
PooledIter. - Pooled
Iter anchored-pool - Convert a
CursorLendingIteratorinto aCursorPooledIteratorby storing recently accessed items in reusable buffers. - Pooled
Lender Adapter lender - An adapter for
PooledIteratorwhich implementslender::Lender. - Pooled
Lending Iterator Adapter lending-iterator - An adapter for
PooledIteratorwhich implementslending_iterator::LendingIterator. - Threadsafe
Pool Item anchored-pool - The type of an item returned by
ThreadsafePooledIter. - Threadsafe
Pooled Iter anchored-pool - Convert a
CursorLendingIteratorinto aCursorPooledIteratorby storing recently accessed items in reusable buffers.
Traits§
- Comparator
- Interface for comparing keys (or entries) of a sorted collection.
- Cursor
Iterator - A
CursorIteratorprovides access to the entries of some sorted collection, and can move its current position in either direction. - Cursor
Lending Iterator - A
CursorLendingIteratorprovides access to the entries of some sorted collection, and can move its current position in either direction. - Cursor
Pooled Iterator - A
CursorPooledIteratorprovides access to the entries of some sorted collection, and can move its current position in either direction. - Item
ToKey - Convert one of the items of an iterator into a
Keyreference, intended for use with aSeekableLendingIterator. - Lend
Item - Trait for getting the item of a lending iterator.
- Pooled
Iterator - A
PooledIteratoris similar to a lending iterator (which can lend one item at a time), but can make use of a buffer pool to lend out multiple items at a time. - Seekable
- A trait adding seek functionality to one of the cursor iterator traits.
- Seekable
Iterator - An
Iteratorwith cursor methods fromCursorIteratorand the ability to seek fromSeekable. - Seekable
Lending Iterator - A lending iterator with cursor methods from
CursorLendingIteratorand the ability to seek fromSeekable. - Seekable
Pooled Iterator - A
PooledIteratorwith cursor methods fromCursorPooledIteratorand the ability to seek fromSeekable.
Type Aliases§
- Lent
Item - The item of a lending iterator, with a particular lifetime.