Skip to main content

Module btree_map

Module btree_map 

Source
Expand description

BTreeMap similar to std::collections::BTreeMap.

§Differences compared to std::collections::BTreeMap

This BTreeMap does not treat a map being out-of-order as unsafe ( since this cannot be guaranteed for all key types in any case ). So CursorMut::with_mutable_key, CursorMutKey::insert_before_unchecked and CursorMutKey::insert_after_unchecked are not marked as unsafe and crates should not rely on arbitrary maps being ordered for safety.

This BTreeMap has the trait Tuning which gives control over the allocation of the map in addition to where it is allocated via the Allocator trait. This and other implementation differences mean that less memory is allocated.

Performance is mostly similar, but clone and serde deserialisation are significantly faster.

§Example

    use pstd::collections::btree_map::BTreeMap;
    let mut mymap = BTreeMap::new();
    mymap.insert("England", "London");
    mymap.insert("France", "Paris");
    println!("The capital of France is {}", mymap["France"]);

§Features

This crate supports the following cargo features:

  • serde : enables serialisation of BTreeMap via serde crate.
  • unsafe-optim : uses unsafe code for extra optimisation.

Structs§

BTreeMap
BTreeMap similar to std::collections::BTreeMap.
Cursor
Cursor returned by BTreeMap::lower_bound, BTreeMap::upper_bound.
CursorMut
Cursor that allows mutation of map, returned by BTreeMap::lower_bound_mut, BTreeMap::upper_bound_mut.
CursorMutKey
Cursor that allows mutation of map keys, returned by CursorMut::with_mutable_key.
CustomTuning
Implementation of Tuning. Default branch is 64, default allocation unit is 16.
ExtractIf
Iterator returned by BTreeMap::extract_if.
IntoIter
Consuming iterator for BTreeMap.
IntoKeys
Consuming iterator returned by BTreeMap::into_keys.
IntoValues
Consuming iterator returned by BTreeMap::into_values.
Iter
Iterator returned by BTreeMap::iter.
IterMut
Iterator returned by BTreeMap::iter_mut.
Keys
Iterator returned by BTreeMap::keys.
OccupiedEntry
Occupied Entry.
OccupiedError
Error returned by BTreeMap::try_insert.
Range
Iterator returned by BTreeMap::range.
RangeMut
Iterator returned by BTreeMap::range_mut.
UnorderedKeyError
Error type for CursorMut::insert_before and CursorMut::insert_after.
VacantEntry
Vacant Entry.
Values
Iterator returned by BTreeMap::values.
ValuesMut
Iterator returned by BTreeMap::values_mut.

Enums§

Entry
Entry in BTreeMap, returned by BTreeMap::entry.
FullAction
Type returned by Tuning::full_action.

Traits§

Tuning
Trait for controlling storage allocation for BTreeMap.

Type Aliases§

DefaultTuning
Default allocation tuning.