pub struct BTreeMap<M: Memory, K: Storable, V: Storable> { /* 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.

The size of the key/value must be <= the max key/value sizes configured for the map. Otherwise, an InsertError is returned.

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 a reference to the memory used by the map.

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 begin with the given prefix. If the optional offset is set, the iterator returned will start from the entry that contains this offset (while still iterating over all remaining entries that begin with the given prefix).

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.