Trait shawshank::Map [] [src]

pub trait Map {
    type Key;
    type Value;
    fn new() -> Self;
    fn with_capacity(_: usize) -> Self;
    fn len(&self) -> usize;
    fn insert(&mut self, _: Self::Key, _: Self::Value) -> Option<Self::Value>;
    fn get(&self, _: Self::Key) -> Option<&Self::Value>;
    fn remove(&mut self, _: Self::Key) -> Option<Self::Value>;
    fn shrink_to_fit(&mut self);
}

The interface for the key-value map internal to an ArenaSet.

The Entry API is not supported, because it can't be used as is, anyway: the reference passed as a key to entry(K) would be to something outside the arena_set, which we absolutely don't want to store in the map. The Entry API would have to be extended to allow changing the key before insertion.

Associated Types

Required Methods

Create an empty map.

This is required for ArenaSet to function properly.

Create an empty map with a capacity hint.

Not all implementations may support this, making it equivalent to Map::new.

Get the number of pairs in the map.

Insert a key-value pair. If there was already an entry for the key, it gets replaced, and the previous returned.

This is required for ArenaSet to function properly.

Get a value by its key.

This is required for ArenaSet to function properly.

Remove a pair by its key.

This is required for ArenaSet to function properly.

Reduce memory usage as much as possible.

Not all implementations may support this, making it a no-op.

Implementors