pub struct SortedIndex { /* private fields */ }Expand description
A sorted index that provides O(log n) lookups using binary search
Implementations§
Source§impl SortedIndex
impl SortedIndex
Sourcepub fn with_capacity(_capacity: usize) -> Self
pub fn with_capacity(_capacity: usize) -> Self
Create a sorted index with pre-allocated capacity
Sourcepub fn insert(&mut self, key: EKey, location: ArchiveLocation)
pub fn insert(&mut self, key: EKey, location: ArchiveLocation)
Insert an entry into the index
Sourcepub fn lookup(&self, key: &EKey) -> Option<&ArchiveLocation>
pub fn lookup(&self, key: &EKey) -> Option<&ArchiveLocation>
Perform a binary search lookup - O(log n)
Sourcepub fn range(
&self,
start: &EKey,
end: &EKey,
) -> impl Iterator<Item = (&EKey, &ArchiveLocation)>
pub fn range( &self, start: &EKey, end: &EKey, ) -> impl Iterator<Item = (&EKey, &ArchiveLocation)>
Get a range of entries between two keys
Sourcepub fn lower_bound(&self, key: &EKey) -> Option<(&EKey, &ArchiveLocation)>
pub fn lower_bound(&self, key: &EKey) -> Option<(&EKey, &ArchiveLocation)>
Find the first entry with key >= target
Sourcepub fn upper_bound(&self, key: &EKey) -> Option<(&EKey, &ArchiveLocation)>
pub fn upper_bound(&self, key: &EKey) -> Option<(&EKey, &ArchiveLocation)>
Find the last entry with key <= target
Sourcepub fn entries(&self) -> impl Iterator<Item = (&EKey, &ArchiveLocation)>
pub fn entries(&self) -> impl Iterator<Item = (&EKey, &ArchiveLocation)>
Get all entries
Sourcepub fn sorted_keys(&mut self) -> &[EKey]
pub fn sorted_keys(&mut self) -> &[EKey]
Get sorted keys (cached)
Sourcepub fn from_hashmap(map: HashMap<EKey, ArchiveLocation>) -> Self
pub fn from_hashmap(map: HashMap<EKey, ArchiveLocation>) -> Self
Create from a HashMap for migration
Sourcepub fn into_btree_map(self) -> BTreeMap<EKey, ArchiveLocation>
pub fn into_btree_map(self) -> BTreeMap<EKey, ArchiveLocation>
Convert to BTreeMap for compatibility
Trait Implementations§
Source§impl Clone for SortedIndex
impl Clone for SortedIndex
Source§fn clone(&self) -> SortedIndex
fn clone(&self) -> SortedIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SortedIndex
impl Debug for SortedIndex
Auto Trait Implementations§
impl Freeze for SortedIndex
impl RefUnwindSafe for SortedIndex
impl Send for SortedIndex
impl Sync for SortedIndex
impl Unpin for SortedIndex
impl UnwindSafe for SortedIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more