[][src]Struct isomorphism::BiMapBuilder

pub struct BiMapBuilder<LH, RH, B> { /* fields omitted */ }

A builder for the bimap. Allows for the parameters used to tune the BiMap to be configured.

Methods

impl BiMapBuilder<RandomState, RandomState, DefaultBitField>[src]

pub fn new() -> Self[src]

Create new builder, ready to be configured.

let map: BiMap<String, String> = BiMapBuilder::new().finish();

impl<LH: BuildHasher, RH: BuildHasher, B: BitField> BiMapBuilder<LH, RH, B>[src]

pub fn capacity(self, capacity: usize) -> Self[src]

Sets the initial capacity of the bimap. It is not guaranteed that at least capacity elements can be inserted before the map needs to be resized, but it is likely. The only reason the map would need to be resized before that number of elements was inserted is due to a large number of hash collisions.

let map: BiMap<String, String> = BiMapBuilder::new().capacity(1024).finish();

pub fn left_hasher<LH2: BuildHasher>(
    self,
    hasher: LH2
) -> BiMapBuilder<LH2, RH, B>
[src]

Sets the hasher used for left values. By default, the hashmap will use the hashing algorithm used in the standard library hashmap, which is randomly generated and designed to be resistant to DoS attacks. Changing this hasher may lead to hash collisions and performance issues, so do so with care.

use std::collections::hash_map::RandomState;

let map: BiMap<String, String> = BiMapBuilder::new()
            .left_hasher(RandomState::new())
            .finish();

pub fn right_hasher<RH2: BuildHasher>(
    self,
    hasher: RH2
) -> BiMapBuilder<LH, RH2, B>
[src]

Sets the hasher used for right values. By default, the hashmap will use the hashing algorithm used in the standard library hashmap, which is randomly generated and designed to be resistant to DoS attacks. Changing this hasher may lead to hash collisions and performance issues, so do so with care.

use std::collections::hash_map::RandomState;

let map: BiMap<String, String> = BiMapBuilder::new()
            .right_hasher(RandomState::new())
            .finish();

pub fn bitfield<B2: BitField>(self) -> BiMapBuilder<LH, RH, B2>[src]

Sets the size of the bitfield used internall by the hopscotch hashing algorithm. The hopscotch hashing algorithm guarantees that each key is stored within the same "neighbourhood" as its ideal location, regardless of hash collisions. The size of the neighbourhood - and therefore the maximum offset between a key's real location and its ideal location - is equal to the number of bits in this bitfield type. This can be tuned to control the expected number of cache misses needed to do a lookup.

let map: BiMap<String, String, _, _, u16> = BiMapBuilder::new()
            .bitfield::<u16>()
            .finish();

pub fn finish<L, R>(self) -> BiMap<L, R, LH, RH, B>[src]

Takes a completely configured builder, and creates a new BiMap with the specified configurations.

let map: BiMap<String, String> = BiMapBuilder::new().finish();

Trait Implementations

impl Default for BiMapBuilder<RandomState, RandomState, DefaultBitField>[src]

impl<LH: Debug, RH: Debug, B: Debug> Debug for BiMapBuilder<LH, RH, B>[src]

Auto Trait Implementations

impl<LH, RH, B> Send for BiMapBuilder<LH, RH, B> where
    B: Send,
    LH: Send,
    RH: Send

impl<LH, RH, B> Sync for BiMapBuilder<LH, RH, B> where
    B: Sync,
    LH: Sync,
    RH: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]