Struct csf::fp::CMap

source ·
pub struct CMap<C, S = BuildDefaultSeededHasher> { /* private fields */ }
Expand description

Finger-printing based compressed static function (immutable map) that maps hashable keys to values of any type.

To represent a function f:X→Y, it uses the space slightly larger than |X|H, where H is the entropy of the distribution of the f values over X. The expected time complexity is O(c) for evaluation and O(|X|c) for construction (not counting building the encoding dictionary), where c is the average codeword length (given in code fragments) of the values.

Implementations§

source§

impl<C: Coding, S: BuildSeededHasher> CMap<C, S>

source

pub fn get_stats<K: Hash + ?Sized, A: AccessStatsCollector>( &self, k: &K, access_stats: &mut A ) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>

Gets the value associated with the given key k and reports statistics to access_stats.

source

pub fn get<K: Hash + ?Sized>( &self, k: &K ) -> Option<<<C as Coding>::Decoder<'_> as Decoder>::Decoded>

Gets the value associated with the given key k.

source§

impl<C: SerializableCoding, S: BuildSeededHasher> CMap<C, S>

source

pub fn write_bytes(&self, bytes_per_value: usize) -> usize

Returns number of bytes which write will write, assuming that each call to write_value writes bytes_per_value bytes.

source

pub fn write<F>(&self, output: &mut dyn Write, write_value: F) -> Result<()>
where F: FnMut(&mut dyn Write, &C::Value) -> Result<()>,

Writes self to the output, using write_value to write values.

source

pub fn read_with_hasher<F>( input: &mut dyn Read, read_value: F, hasher: S ) -> Result<Self>
where F: FnMut(&mut dyn Read) -> Result<C::Value>,

Read self from the input, using read_value to read values (hasher must be the same as used by written BBMap).

source§

impl<C: SerializableCoding> CMap<C>

source

pub fn read<F>(input: &mut dyn Read, read_value: F) -> Result<Self>
where F: FnMut(&mut dyn Read) -> Result<C::Value>,

Reads Self from the input, using read_value to read values. Only BBMaps that use default hasher can be read by this method.

source§

impl<C: Coding, S: BuildSeededHasher> CMap<C, S>

source

pub fn from_slices_with_coding_conf<K, LSC, CSB, BS, BC>( keys: &mut [K], values: &[C::Value], value_coding: C, conf: CMapConf<BC, LSC, CSB, S>, stats: &mut BS ) -> Self

source

pub fn from_slices_with_conf<K, LSC, CSB, BS, BC>( keys: &mut [K], values: &[C::Value], conf: CMapConf<BC, LSC, CSB, S>, stats: &mut BS ) -> Self

source

pub fn from_map_with_coding_conf<K, H, LSC, CSB, BS, BC>( map: &HashMap<K, C::Value, H>, value_coding: C, conf: CMapConf<BC, LSC, CSB, S>, stats: &mut BS ) -> Self

source

pub fn from_map_with_conf<K, H, LSC, CSB, BS, BC>( map: &HashMap<K, C::Value, H>, conf: CMapConf<BC, LSC, CSB, S>, stats: &mut BS ) -> Self

source§

impl<C: Coding> CMap<C>

source

pub fn from_slices_with_coding<K: Hash, BS: BuildStatsCollector>( keys: &mut [K], values: &[C::Value], value_coding: C, stats: &mut BS ) -> Self

source§

impl<V: Hash + Eq + Clone> CMap<Coding<V>>

source

pub fn from_slices<K: Hash, BS: BuildStatsCollector>( keys: &mut [K], values: &[V], stats: &mut BS ) -> Self

source

pub fn from_map<K: Hash + Clone, H, BS: BuildStatsCollector>( map: &HashMap<K, V, H>, stats: &mut BS ) -> Self

Trait Implementations§

source§

impl<K: Hash + Clone, V: Hash + Eq + Clone, H> From<&HashMap<K, V, H>> for CMap<Coding<V>>

source§

fn from(map: &HashMap<K, V, H>) -> Self

Converts to this type from the input type.
source§

impl<K: Hash + Clone, V: Hash + Eq + Clone, H> From<HashMap<K, V, H>> for CMap<Coding<V>>

source§

fn from(map: HashMap<K, V, H>) -> Self

Converts to this type from the input type.
source§

impl<C: GetSize, S> GetSize for CMap<C, S>

source§

fn size_bytes_dyn(&self) -> usize

Returns approximate number of bytes occupied by dynamic (heap) part of self. Same as self.size_bytes() - std::mem::size_of_val(self).
source§

const USES_DYN_MEM: bool = true

true if and only if the variables of this type can use dynamic (heap) memory.
source§

fn size_bytes_content_dyn(&self) -> usize

Returns approximate number of bytes occupied by dynamic (heap) part of self content. It usually equals to size_bytes_dyn(). However, sometimes it is smaller by the amount of memory reserved but not yet used (e.g., size_bytes_content_dyn() only takes into account the length of the vector and not its capacity).
source§

fn size_bytes(&self) -> usize

Returns approximate, total (including heap memory) number of bytes occupied by self.

Auto Trait Implementations§

§

impl<C, S> RefUnwindSafe for CMap<C, S>

§

impl<C, S> Send for CMap<C, S>
where C: Send, S: Send,

§

impl<C, S> Sync for CMap<C, S>
where C: Sync, S: Sync,

§

impl<C, S> Unpin for CMap<C, S>
where C: Unpin, S: Unpin,

§

impl<C, S> UnwindSafe for CMap<C, S>
where C: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.