Struct TreeMap

Source
pub struct TreeMap<K, V, const PREFIX_LEN: usize = DEFAULT_PREFIX_LEN> { /* private fields */ }
Expand description

An ordered map based on an adaptive radix tree.

Implementations§

Source§

impl<K, V> TreeMap<K, V>

Source

pub fn new() -> Self

Create a new, empty crate::TreeMap with the default number of prefix bytes (16).

This function will not pre-allocate anything.

§Examples
use blart::TreeMap;

let map = TreeMap::<Box<[u8]>, ()>::new();
assert_eq!(map, TreeMap::new());
assert!(map.is_empty());
Source§

impl<K, V, const PREFIX_LEN: usize> TreeMap<K, V, PREFIX_LEN>

Source

pub fn with_prefix_len() -> Self

Create a new, empty crate::TreeMap.

This function will not pre-allocate anything.

§Examples
use blart::TreeMap;

let map = TreeMap::<Box<[u8]>, (), 16>::with_prefix_len();
assert_eq!(map, TreeMap::new());
assert!(map.is_empty());
Source

pub fn clear(&mut self)

Clear the map, removing all elements.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(map.len(), 1);

map.clear();
assert!(map.is_empty());
assert!(map.get([1, 2, 3].as_ref()).is_none());
Source

pub fn into_raw(tree: Self) -> Option<OpaqueNodePtr<K, V, PREFIX_LEN>>

Consume the tree, returning a raw pointer to the root node.

If the results is None, this means the tree is empty.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(map.len(), 1);

let root = TreeMap::into_raw(map);
assert!(root.is_some());

// SAFETY: The root pointer came directly from the `into_raw` result.
let _map = unsafe { TreeMap::from_raw(root) }.unwrap();
Source

pub unsafe fn from_raw( root: Option<OpaqueNodePtr<K, V, PREFIX_LEN>>, ) -> Result<Self, MalformedTreeError<K, V, PREFIX_LEN>>
where K: AsBytes,

Constructs a TreeMap from a raw node pointer.

§Safety

The raw pointer must have been previously returned by a call to TreeMap::into_raw.

This function also requires that this the given root pointer is unique, and that there are no other pointers into the tree.

§Errors

This function runs a series of checks to ensure that the returned tree is well-formed. See WellFormedChecker for details on the requirements.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(map.len(), 1);

let root = TreeMap::into_raw(map);
assert!(root.is_some());

// SAFETY: The root pointer came directly from the `into_raw` result.
let _map = unsafe { TreeMap::from_raw(root) }.unwrap();
Source

pub fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Returns a reference to the value corresponding to the key.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(*map.get([1, 2, 3].as_ref()).unwrap(), 'a');
Source

pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Returns the key-value pair corresponding to the supplied key.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(map.get_key_value([1, 2, 3].as_ref()).unwrap(), (&Box::from([1, 2, 3]), &'a'));
Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Returns a mutable reference to the value corresponding to the key.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
assert_eq!(map[[1, 2, 3].as_ref()], 'a');

*map.get_mut([1, 2, 3].as_ref()).unwrap() = 'b';
assert_eq!(map[[1, 2, 3].as_ref()], 'b');

While an element from the tree is mutably referenced, no other operation on the tree can happen.

use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();


let value = map.get_mut(&[1, 2, 3]).unwrap();
assert_eq!(*value, 'a');

assert_eq!(*map[[1, 2, 3].as_ref()], 'a');

*value = 'b';
drop(value);
Source

pub fn fuzzy<'a, 'b, Q>( &'a self, key: &'b Q, max_edit_dist: usize, ) -> Fuzzy<'a, 'b, K, V, PREFIX_LEN>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Makes a fuzzy search in the tree by key, returning all keys and values that are less than or equal to max_edit_dist.

This is done by using Levenshtein distance

§Examples
use blart::TreeMap;

let mut map: TreeMap<_, _> = TreeMap::new();

map.insert(c"abc", 0);
map.insert(c"abd", 1);
map.insert(c"abdefg", 2);

let fuzzy: Vec<_> = map.fuzzy(c"ab", 2).collect();
assert_eq!(fuzzy, vec![(&c"abd", &1), (&c"abc", &0)]);
Source

pub fn fuzzy_mut<'a, 'b, Q>( &'a mut self, key: &'b Q, max_edit_dist: usize, ) -> FuzzyMut<'a, 'b, K, V, PREFIX_LEN>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Makes a fuzzy search in the tree by key, returning all keys and values that are less than or equal to max_edit_dist.

This is done by using Levenshtein distance

§Examples
use blart::TreeMap;

let mut map: TreeMap<_, _> = TreeMap::new();

map.insert(c"abc", 0);
map.insert(c"abd", 1);
map.insert(c"abdefg", 2);

let fuzzy: Vec<_> = map.fuzzy_mut(c"ab", 2).collect();
assert_eq!(fuzzy, vec![(&c"abd", &mut 1), (&c"abc", &mut 0)]);
Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Returns true if the map contains a value for the specified key.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();

assert!(map.contains_key([1, 2, 3].as_ref()));
Source

pub fn first_key_value(&self) -> Option<(&K, &V)>

Returns the first key-value pair in the map. The key in this pair is the minimum key in the map.

If the tree is empty, returns None.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();

assert_eq!(map.first_key_value().unwrap(), (&[1, 2, 3].into(), &'a'));
Source

pub fn pop_first(&mut self) -> Option<(K, V)>

Removes and returns the first element in the map. The key of this element is the minimum key that was in the map.

If the tree is empty, returns None.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();

assert_eq!(map.pop_first().unwrap(), (Box::from([1, 2, 3]), 'a'));
Source

pub fn last_key_value(&self) -> Option<(&K, &V)>

Returns the last key-value pair in the map. The key in this pair is the maximum key in the map.

If the tree is empty, returns None.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
map.try_insert(Box::new([2, 3, 4]), 'b').unwrap();

assert_eq!(map.last_key_value().unwrap(), (&Box::from([2, 3, 4]), &'b'));
Source

pub fn pop_last(&mut self) -> Option<(K, V)>

Removes and returns the last element in the map. The key of this element is the maximum key that was in the map.

If the tree is empty, returns None.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
map.try_insert(Box::new([2, 3, 4]), 'b').unwrap();

assert_eq!(map.pop_last().unwrap(), (Box::from([2, 3, 4]), 'b'));
Source

pub fn insert(&mut self, key: K, value: V) -> Option<V>
where K: NoPrefixesBytes,

Insert a key-value pair into the map.

If the map did not have this key present, Ok(None) is returned.

If the map did have this key present, the value is updated, and the old value is returned.

Unlike try_insert, this function will not return an error, because the contract of the NoPrefixesBytes ensures that the given key type will never be a prefix of an existing value.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<u128, char>::new();

assert!(map.insert(123, 'a').is_none());
assert!(map.insert(234, 'b').is_none());
assert_eq!(map.insert(234, 'c'), Some('b'));

assert_eq!(map.len(), 2);
Source

pub fn try_insert( &mut self, key: K, value: V, ) -> Result<Option<V>, InsertPrefixError>
where K: AsBytes,

Inserts a key-value pair into the map.

If the map did not have this key present, Ok(None) is returned.

If the map did have this key present, the value is updated, and the old value is returned.

§Errors
  • If the map has an existing key, such that the new key is a prefix of the existing key or vice versa, then it returns an error.
§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

assert!(map.try_insert(Box::new([1, 2, 3]), 'a').unwrap().is_none());
assert!(map.try_insert(Box::new([2, 3, 4]), 'b').unwrap().is_none());
// This function call errors because the key is a prefix of the existing key
assert!(map.try_insert(Box::new([2, 3, 4, 5]), 'c').is_err());
assert_eq!(map.try_insert(Box::new([2, 3, 4]), 'd').unwrap(), Some('b'));

assert_eq!(map.len(), 2);
Source

pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Removes a key from the map, returning the stored key and value if the key was previously in the map.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
map.try_insert(Box::new([2, 3, 4]), 'b').unwrap();

assert_eq!(map.remove_entry([2, 3, 4].as_ref()).unwrap(), (Box::from([2, 3, 4]), 'b'))
Source

pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Removes a key from the map, returning the value at the key if the key was previously in the map.

§Examples
use blart::TreeMap;

let mut map = TreeMap::<Box<[u8]>, char>::new();

map.try_insert(Box::new([1, 2, 3]), 'a').unwrap();
map.try_insert(Box::new([2, 3, 4]), 'b').unwrap();

assert_eq!(map.remove([2, 3, 4].as_ref()).unwrap(), 'b');
assert_eq!(map.remove([2, 3, 4].as_ref()), None);
Source

pub fn range<Q, R>(&self, range: R) -> Range<'_, K, V, PREFIX_LEN>
where Q: AsBytes + ?Sized, K: Borrow<Q> + AsBytes, R: RangeBounds<Q>,

Constructs a double-ended iterator over a sub-range of elements in the map.

The simplest way is to use the range syntax min..max, thus range(min..max) will yield elements from min (inclusive) to max (exclusive). The range may also be entered as (Bound<T>, Bound<T>), so for example range((Excluded(4), Included(10))) will yield a left-exclusive, right-inclusive range from 4 to 10.

§Examples
use blart::TreeMap;
use std::ops::Bound::Included;

let mut map = TreeMap::<u8, _>::new();
map.try_insert(3, "a").unwrap();
map.try_insert(5, "b").unwrap();
map.try_insert(8, "c").unwrap();

for (key, &value) in map.range((Included(&4), Included(&8))) {
    println!("{key:?}: {value}");
}
assert_eq!(map.range(&4..).next(), Some((&5, &"b")));
Source

pub fn range_mut<Q, R>(&mut self, range: R) -> RangeMut<'_, K, V, PREFIX_LEN>
where Q: AsBytes + ?Sized, K: Borrow<Q> + AsBytes, R: RangeBounds<Q>,

Constructs a mutable double-ended iterator over a sub-range of elements in the map.

The simplest way is to use the range syntax min..max, thus range_mut(min..max) will yield elements from min (inclusive) to max (exclusive). The range may also be entered as (Bound<T>, Bound<T>), so for example range_mut((Excluded(4), Included(10))) will yield a left-exclusive, right-inclusive range from 4 to 10.

§Examples
use blart::TreeMap;

let mut map: TreeMap<_, i32> = TreeMap::new();

for (key, value) in [("Alice", 0), ("Bob", 0), ("Carol", 0), ("Cheryl", 0)] {
    let _ = map.try_insert(key, value).unwrap();
}

for (name, balance) in map.range_mut("B"..="Cheryl") {
    *balance += 100;

    if name.starts_with('C') {
        *balance *= 2;
    }
}

for (name, balance) in &map {
    println!("{name} => {balance}");
}

assert_eq!(map["Alice"], 0);
assert_eq!(map["Bob"], 100);
assert_eq!(map["Carol"], 200);
assert_eq!(map["Cheryl"], 200);
Source

pub fn into_keys(self) -> IntoKeys<K, V, PREFIX_LEN>

Creates a consuming iterator visiting all the keys, in sorted order. The map cannot be used after calling this. The iterator element type is K.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

let mut iter = map.into_keys();

assert_eq!(iter.next().unwrap(), 0);
assert_eq!(iter.next().unwrap(), 1);
assert_eq!(iter.next().unwrap(), 2);
assert_eq!(iter.next().unwrap(), 3);
assert_eq!(iter.next().unwrap(), 4);
assert_eq!(iter.next(), None);
Source

pub fn into_values(self) -> IntoValues<K, V, PREFIX_LEN>

Creates a consuming iterator visiting all the values, in order by key. The map cannot be used after calling this. The iterator element type is V.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

let mut iter = map.into_values();

assert_eq!(iter.next().unwrap(), 'd');
assert_eq!(iter.next().unwrap(), 'c');
assert_eq!(iter.next().unwrap(), 'b');
assert_eq!(iter.next().unwrap(), 'a');
assert_eq!(iter.next().unwrap(), 'z');
assert_eq!(iter.next(), None);
Source

pub fn iter(&self) -> Iter<'_, K, V, PREFIX_LEN>

Gets an iterator over the entries of the map, sorted by key.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

let mut iter = map.iter();

assert_eq!(iter.next().unwrap(), (&0, &'d'));
assert_eq!(iter.next().unwrap(), (&1, &'c'));
assert_eq!(iter.next().unwrap(), (&2, &'b'));
assert_eq!(iter.next().unwrap(), (&3, &'a'));
assert_eq!(iter.next().unwrap(), (&4, &'z'));
assert_eq!(iter.next(), None);
Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V, PREFIX_LEN>

Gets a mutable iterator over the entries of the map, sorted by key.

§Examples
use blart::TreeMap;

let mut map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

for (_key, value) in map.iter_mut() {
    value.make_ascii_uppercase();
}

assert_eq!(map[&0], 'D');
assert_eq!(map[&1], 'C');
assert_eq!(map[&2], 'B');
assert_eq!(map[&3], 'A');
assert_eq!(map[&4], 'Z');
Source

pub fn keys(&self) -> Keys<'_, K, V, PREFIX_LEN>

Gets an iterator over the keys of the map, in sorted order.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

let mut iter = map.keys();

assert_eq!(iter.next().unwrap(), &0);
assert_eq!(iter.next().unwrap(), &1);
assert_eq!(iter.next().unwrap(), &2);
assert_eq!(iter.next().unwrap(), &3);
assert_eq!(iter.next().unwrap(), &4);
assert_eq!(iter.next(), None);
Source

pub fn values(&self) -> Values<'_, K, V, PREFIX_LEN>

Gets an iterator over the values of the map, in order by key.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

let mut iter = map.values();

assert_eq!(iter.next().unwrap(), &'d');
assert_eq!(iter.next().unwrap(), &'c');
assert_eq!(iter.next().unwrap(), &'b');
assert_eq!(iter.next().unwrap(), &'a');
assert_eq!(iter.next().unwrap(), &'z');
assert_eq!(iter.next(), None);
Source

pub fn values_mut(&mut self) -> ValuesMut<'_, K, V, PREFIX_LEN>

Gets a mutable iterator over the values of the map, in order by key.

§Examples
use blart::TreeMap;

let mut map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

for value in map.values_mut() {
    value.make_ascii_uppercase();
}

assert_eq!(map[&0], 'D');
assert_eq!(map[&1], 'C');
assert_eq!(map[&2], 'B');
assert_eq!(map[&3], 'A');
assert_eq!(map[&4], 'Z');
Source

pub fn prefix(&self, prefix: &[u8]) -> Prefix<'_, K, V, PREFIX_LEN>
where K: AsBytes,

Gets an iterator over the entries of the map that start with prefix

§Examples
use blart::TreeMap;

let mut map = TreeMap::new();
map.insert(c"abcde", 0);
map.insert(c"abcdexxx", 0);
map.insert(c"abcdexxy", 0);
map.insert(c"abcdx", 0);
map.insert(c"abcx", 0);
map.insert(c"bx", 0);

let p: Vec<_> = map.prefix(c"abcde".to_bytes()).collect();

assert_eq!(p, vec![(&c"abcde", &0), (&c"abcdexxx", &0), (&c"abcdexxy", &0)]);
Source

pub fn prefix_mut(&mut self, prefix: &[u8]) -> PrefixMut<'_, K, V, PREFIX_LEN>
where K: AsBytes,

Gets a mutable iterator over the entries of the map that start with prefix

§Examples
use blart::TreeMap;

let mut map = TreeMap::new();
map.insert(c"abcde", 0);
map.insert(c"abcdexxx", 0);
map.insert(c"abcdexxy", 0);
map.insert(c"abcdx", 0);
map.insert(c"abcx", 0);
map.insert(c"bx", 0);

let p: Vec<_> = map.prefix_mut(c"abcde".to_bytes()).collect();

assert_eq!(p, vec![(&c"abcde", &mut 0), (&c"abcdexxx", &mut 0), (&c"abcdexxy", &mut 0)]);
Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

§Examples
use blart::TreeMap;

let map: TreeMap<_, char> = ['d', 'c', 'b', 'a', 'z'].into_iter()
    .enumerate()
    .collect();

assert_eq!(map.len(), 5);
Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

§Examples
use blart::TreeMap;

let map = TreeMap::<Box<[u8]>, ()>::new();
assert!(map.is_empty());
Source§

impl<K, V, const PREFIX_LEN: usize> TreeMap<K, V, PREFIX_LEN>

Source

pub fn try_entry( &mut self, key: K, ) -> Result<Entry<'_, K, V, PREFIX_LEN>, InsertPrefixError>
where K: AsBytes,

Tries to get the given key’s corresponding entry in the map for in-place manipulation.

Source

pub fn try_entry_ref<'a, 'b, Q>( &'a mut self, key: &'b Q, ) -> Result<EntryRef<'a, 'b, K, V, Q, PREFIX_LEN>, InsertPrefixError>
where K: AsBytes + Borrow<Q> + From<&'b Q>, Q: AsBytes + ?Sized,

Tries to get the given key’s corresponding entry in the map for in-place manipulation.

Source

pub fn entry(&mut self, key: K) -> Entry<'_, K, V, PREFIX_LEN>
where K: NoPrefixesBytes,

Gets the given key’s corresponding entry in the map for in-place manipulation.

Source

pub fn entry_ref<'a, 'b, Q>( &'a mut self, key: &'b Q, ) -> EntryRef<'a, 'b, K, V, Q, PREFIX_LEN>

Gets the given key’s corresponding entry in the map for in-place manipulation.

Trait Implementations§

Source§

impl<K, V, const PREFIX_LEN: usize> Clone for TreeMap<K, V, PREFIX_LEN>
where K: Clone + AsBytes, V: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Debug for TreeMap<K, V, PREFIX_LEN>
where K: Debug, V: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Default for TreeMap<K, V, PREFIX_LEN>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Drop for TreeMap<K, V, PREFIX_LEN>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, K, V, const PREFIX_LEN: usize> Extend<(&'a K, &'a V)> for TreeMap<K, V, PREFIX_LEN>
where K: Copy + NoPrefixesBytes, V: Copy,

Source§

fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Extend<(K, V)> for TreeMap<K, V, PREFIX_LEN>
where K: NoPrefixesBytes,

Source§

fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K, V, const PREFIX_LEN: usize, const N: usize> From<[(K, V); N]> for TreeMap<K, V, PREFIX_LEN>
where K: NoPrefixesBytes,

Source§

fn from(arr: [(K, V); N]) -> Self

Converts to this type from the input type.
Source§

impl<K, V, const PREFIX_LEN: usize> FromIterator<(K, V)> for TreeMap<K, V, PREFIX_LEN>
where K: NoPrefixesBytes,

Source§

fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Hash for TreeMap<K, V, PREFIX_LEN>
where K: Hash, V: Hash,

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Q, K, V, const PREFIX_LEN: usize> Index<&Q> for TreeMap<K, V, PREFIX_LEN>
where K: Borrow<Q> + AsBytes, Q: AsBytes + ?Sized,

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: &Q) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, K, V, const PREFIX_LEN: usize> IntoIterator for &'a TreeMap<K, V, PREFIX_LEN>

Source§

type IntoIter = Iter<'a, K, V, PREFIX_LEN>

Which kind of iterator are we turning this into?
Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, K, V, const PREFIX_LEN: usize> IntoIterator for &'a mut TreeMap<K, V, PREFIX_LEN>

Source§

type IntoIter = IterMut<'a, K, V, PREFIX_LEN>

Which kind of iterator are we turning this into?
Source§

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> IntoIterator for TreeMap<K, V, PREFIX_LEN>

Source§

type IntoIter = IntoIter<K, V, PREFIX_LEN>

Which kind of iterator are we turning this into?
Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Ord for TreeMap<K, V, PREFIX_LEN>
where K: Ord, V: Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> PartialEq for TreeMap<K, V, PREFIX_LEN>
where K: PartialEq, V: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K, V, const PREFIX_LEN: usize> PartialOrd for TreeMap<K, V, PREFIX_LEN>
where K: PartialOrd, V: PartialOrd,

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<K, V, const PREFIX_LEN: usize> Eq for TreeMap<K, V, PREFIX_LEN>
where K: Eq, V: Eq,

Source§

impl<K, V, const PREFIX_LEN: usize> Send for TreeMap<K, V, PREFIX_LEN>
where K: Send, V: Send,

Source§

impl<K, V, const PREFIX_LEN: usize> Sync for TreeMap<K, V, PREFIX_LEN>
where K: Sync, V: Sync,

Auto Trait Implementations§

§

impl<K, V, const PREFIX_LEN: usize> Freeze for TreeMap<K, V, PREFIX_LEN>

§

impl<K, V, const PREFIX_LEN: usize> RefUnwindSafe for TreeMap<K, V, PREFIX_LEN>

§

impl<K, V, const PREFIX_LEN: usize> Unpin for TreeMap<K, V, PREFIX_LEN>
where K: Unpin, V: Unpin,

§

impl<K, V, const PREFIX_LEN: usize> UnwindSafe for TreeMap<K, V, PREFIX_LEN>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.