pub struct TreeBag<K, V>(_);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>>where
K: Borrow<Q> + Ord,
Q: Ord + ?Sized,
pub fn get<Q>(&self, key: &Q) -> Option<&Vec<V>>where K: Borrow<Q> + Ord, Q: Ord + ?Sized,
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