pub struct BTreeMap<K, V, M>where
    K: BoundedStorable + Ord + Clone,
    V: BoundedStorable,
    M: Memory,
{ /* private fields */ }
Expand description

A “stable” map based on a B-tree.

The implementation is based on the algorithm outlined in “Introduction to Algorithms” by Cormen et al.

Implementations§

Initializes a BTreeMap.

If the memory provided already contains a BTreeMap, then that map is loaded. Otherwise, a new BTreeMap instance is created.

Creates a new instance a BTreeMap.

The given memory is assumed to be exclusively reserved for this data structure and that it starts at address zero. Typically memory will be an instance of RestrictedMemory.

When initialized, the data structure has the following memory layout:

| BTreeHeader | Allocator | … free memory for nodes |

See Allocator for more details on its own memory layout.

Loads the map from memory.

Inserts a key-value pair into the map.

The previous value of the key, if present, is returned.

PRECONDITION: key.to_bytes().len() <= Key::MAX_SIZE value.to_bytes().len() <= Value::MAX_SIZE

Returns the value associated with the given key if it exists.

Returns true if the key exists in the map, false otherwise.

Returns true if the map contains no elements.

Returns the number of elements in the map.

Returns the underlying memory.

Removes a key from the map, returning the previous value at the key if it exists.

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

Returns an iterator over the entries in the map where keys belong to the specified range.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.