pub struct TreeBag<K, V>(/* private fields */);
Expand description
Ordered counter structure.
§Example :
use yadf::TreeBag;
let bag: TreeBag<i32, &str> = vec![
(3, "hello world"),
(3, "foobar"),
(7, "fizz"),
(7, "buzz"),
(6, "rust"),
].into_iter().collect();
assert_eq!(bag[&3], ["hello world", "foobar"]);
assert_eq!(bag[&7], ["fizz", "buzz"]);
assert_eq!(bag[&6], ["rust"]);
Implementations§
source§impl<K, V> TreeBag<K, V>
impl<K, V> TreeBag<K, V>
sourcepub const fn duplicates(&self) -> Replicates<'_, K, V>
pub const fn duplicates(&self) -> Replicates<'_, K, V>
Provides a view only on the buckets containing more than one element.
sourcepub const fn replicates(&self, factor: Factor) -> Replicates<'_, K, V>
pub const fn replicates(&self, factor: Factor) -> Replicates<'_, K, V>
Provides a view only on the buckets as constrained by the replication Factor
.
sourcepub fn as_inner_mut(&mut self) -> &mut BTreeMap<K, Vec<V>>
pub fn as_inner_mut(&mut self) -> &mut BTreeMap<K, Vec<V>>
Mutably borrows the backing BTreeMap
of the bag.
sourcepub fn into_inner(self) -> BTreeMap<K, Vec<V>>
pub fn into_inner(self) -> BTreeMap<K, Vec<V>>
sourcepub fn get<Q>(&self, key: &Q) -> Option<&Vec<V>>
pub fn get<Q>(&self, key: &Q) -> Option<&Vec<V>>
Returns a reference to the bucket corresponding to the key.
Trait Implementations§
source§impl<K: Ord, V> Extend<(K, V)> for TreeBag<K, V>
impl<K: Ord, V> Extend<(K, V)> for TreeBag<K, V>
source§fn extend<I>(&mut self, key_value_iter: I)where
I: IntoIterator<Item = (K, V)>,
fn extend<I>(&mut self, key_value_iter: I)where
I: IntoIterator<Item = (K, V)>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for TreeBag<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TreeBag<K, V>
impl<K, V> Sync for TreeBag<K, V>
impl<K, V> Unpin for TreeBag<K, V>
impl<K, V> UnwindSafe for TreeBag<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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