pub struct StableBTreeSet<K: Storable + Ord + Clone, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
Governed upstream BTreeSet; initialization and failures follow upstream contracts.
Implementations§
Source§impl<K: Storable + Ord + Clone, M: Memory> StableBTreeSet<K, M>
impl<K: Storable + Ord + Clone, M: Memory> StableBTreeSet<K, M>
Sourcepub fn new(memory: RuntimeMemory<M>) -> Self
pub fn new(memory: RuntimeMemory<M>) -> Self
Create a new collection, replacing any prior collection in the selected memory. This is destructive even when a valid collection already exists.
§Panics
Panics on insufficient memory or codec/backing failure.
Sourcepub fn init(memory: RuntimeMemory<M>) -> Self
pub fn init(memory: RuntimeMemory<M>) -> Self
Open a recognized retained collection; initialize a new one when memory is empty or has foreign magic. Foreign contents may be overwritten. This is not a corruption-recovery or schema-admission operation.
§Panics
Panics for unsupported recognized layouts, invalid retained contents, insufficient memory or codec/backing failure.
Sourcepub fn load(memory: RuntimeMemory<M>) -> Self
pub fn load(memory: RuntimeMemory<M>) -> Self
Load an existing tree without initializing a replacement.
§Panics
Panics for missing/foreign headers, unsupported layouts or backing failure. Record decoding can also panic when records are subsequently accessed.
Sourcepub fn insert(&mut self, key: K) -> bool
pub fn insert(&mut self, key: K) -> bool
Delegates to upstream BTreeSet::insert with the governed allocation.
Sourcepub fn contains(&self, key: &K) -> bool
pub fn contains(&self, key: &K) -> bool
Delegates to upstream BTreeSet::contains with the governed allocation.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Delegates to upstream BTreeSet::is_empty with the governed allocation.
Sourcepub fn remove(&mut self, key: &K) -> bool
pub fn remove(&mut self, key: &K) -> bool
Delegates to upstream BTreeSet::remove with the governed allocation.
Sourcepub fn first(&self) -> Option<K>
pub fn first(&self) -> Option<K>
Delegates to upstream BTreeSet::first with the governed allocation.
Sourcepub fn last(&self) -> Option<K>
pub fn last(&self) -> Option<K>
Delegates to upstream BTreeSet::last with the governed allocation.
Sourcepub fn pop_first(&mut self) -> Option<K>
pub fn pop_first(&mut self) -> Option<K>
Delegates to upstream BTreeSet::pop_first with the governed allocation.
Sourcepub fn pop_last(&mut self) -> Option<K>
pub fn pop_last(&mut self) -> Option<K>
Delegates to upstream BTreeSet::pop_last with the governed allocation.
Sourcepub fn iter(&self) -> SetIter<'_, K, M>
pub fn iter(&self) -> SetIter<'_, K, M>
Delegates to upstream BTreeSet::iter with the governed allocation.
Sourcepub fn range(&self, key_range: impl RangeBounds<K>) -> SetIter<'_, K, M>
pub fn range(&self, key_range: impl RangeBounds<K>) -> SetIter<'_, K, M>
Delegates to upstream BTreeSet::range with the governed allocation.