Struct Map

Source
pub struct Map<TKey, TValue>(/* private fields */);
Expand description

A small hashtable-like map with byte sized key indecies.

Implementations§

Source§

impl<K, V> Map<K, V>
where K: Collapse,

Source

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

Get an Entry for the key that lets you get or insert the value

Source

pub fn clean(&mut self)

Remove all empty pages from this instance.

Source

pub fn len(&self) -> usize

The number of entries currently in this map

This is an iterating count over all slots in all current pages, if possible store it in a temporary instead of re-calling it.

Source

pub fn is_empty(&self) -> bool

Is this map empty

Source

pub fn num_pages(&self) -> usize

The number of pages currently in this map

Source

pub fn into_pages(self) -> Vec<Page<K, V>>

Consume the instance, returning all pages.

Source

pub fn pages(&self) -> Pages<'_, K, V>

An iterator over all pages

Source

pub fn pages_mut(&mut self) -> PagesMut<'_, K, V>

A mutable iterator over all pages

Source

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

An iterator over all elements in the map

Source

pub fn keys(&self) -> impl Iterator<Item = &K>

An iterator over all the keys in the map

Source

pub fn values(&self) -> impl Iterator<Item = &V>

An iterator over all the values in the map

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>

A mutable iterator over all the values in the map

Source

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

A mutable iterator over all elements in the map

Source

pub fn new() -> Self

Create a new empty Map

Source

pub fn with_capacity(pages: usize) -> Self

Create a new empty Map with a specific number of pages pre-allocated

Source

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

Get a mutable reference of the value corresponding to this key if it is in the map.

Source

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

Search the map for entry corresponding to this key

Source

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

Get a reference of the value corresponding to this key if it is in the map.

Source

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

Remove the entry corresponding to this key in the map, returning the value if it was present

Source

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

Insert a new key-value entry into this map, returning the pervious value if it was present

Source

pub fn reverse(self) -> Map<V, K>
where V: Collapse,

Consume this Map by swapping its keys and values around.

Trait Implementations§

Source§

impl<TKey: Clone, TValue: Clone> Clone for Map<TKey, TValue>

Source§

fn clone(&self) -> Map<TKey, TValue>

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<TKey: Debug, TValue: Debug> Debug for Map<TKey, TValue>

Source§

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

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

impl<K: Collapse, V> Default for Map<K, V>

Source§

fn default() -> Self

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

impl<K: Collapse, V> Extend<(K, V)> for Map<K, V>

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: Collapse, V> FromIterator<(K, V)> for Map<K, V>

Source§

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

Creates a value from an iterator. Read more
Source§

impl<TKey: Hash, TValue: Hash> Hash for Map<TKey, TValue>

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<K, Q, V> Index<&Q> for Map<K, V>
where K: Collapse + Borrow<Q>, Q: ?Sized + Collapse + Eq,

Source§

type Output = V

The returned type after indexing.
Source§

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

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

impl<K, Q, V> IndexMut<&Q> for Map<K, V>
where K: Collapse + Borrow<Q>, Q: ?Sized + Collapse + Eq,

Source§

fn index_mut(&mut self, key: &Q) -> &mut Self::Output

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

impl<K: Collapse, V> IntoIterator for Map<K, V>

Source§

fn into_iter(self) -> Self::IntoIter

Consume this map into an iterator over all currently inserted entries

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, V>

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

impl<TKey: PartialEq, TValue: PartialEq> PartialEq for Map<TKey, TValue>

Source§

fn eq(&self, other: &Map<TKey, TValue>) -> 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<TKey: Eq, TValue: Eq> Eq for Map<TKey, TValue>

Source§

impl<TKey, TValue> StructuralPartialEq for Map<TKey, TValue>

Auto Trait Implementations§

§

impl<TKey, TValue> Freeze for Map<TKey, TValue>

§

impl<TKey, TValue> RefUnwindSafe for Map<TKey, TValue>
where TKey: RefUnwindSafe, TValue: RefUnwindSafe,

§

impl<TKey, TValue> Send for Map<TKey, TValue>
where TKey: Send, TValue: Send,

§

impl<TKey, TValue> Sync for Map<TKey, TValue>
where TKey: Sync, TValue: Sync,

§

impl<TKey, TValue> Unpin for Map<TKey, TValue>
where TKey: Unpin, TValue: Unpin,

§

impl<TKey, TValue> UnwindSafe for Map<TKey, TValue>
where TKey: UnwindSafe, TValue: UnwindSafe,

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> Collapse for T
where T: Hash + Eq + ?Sized,

Source§

fn collapse(&self) -> u8

Create the index key for this instance. This is similar in use to Hash::hash().
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.