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>
impl<C: Coding, S: BuildSeededHasher> CMap<C, S>
Source§impl<C: SerializableCoding, S: BuildSeededHasher> CMap<C, S>
impl<C: SerializableCoding, S: BuildSeededHasher> CMap<C, S>
Sourcepub fn write_bytes(&self, bytes_per_value: usize) -> usize
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§impl<C: SerializableCoding> CMap<C>
impl<C: SerializableCoding> CMap<C>
Source§impl<C: Coding, S: BuildSeededHasher> CMap<C, S>
impl<C: Coding, S: BuildSeededHasher> CMap<C, S>
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,
) -> Selfwhere
K: Hash,
LSC: LevelSizeChooser,
CSB: CollisionSolverBuilder + IsLossless,
BS: BuildStatsCollector,
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,
) -> Selfwhere
K: Hash,
LSC: LevelSizeChooser,
CSB: CollisionSolverBuilder + IsLossless,
BS: BuildStatsCollector,
BC: BuildCoding<C::Value, Coding = C>,
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,
) -> Selfwhere
K: Hash + Clone,
LSC: LevelSizeChooser,
CSB: CollisionSolverBuilder + IsLossless,
BS: BuildStatsCollector,
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,
) -> Selfwhere
K: Hash + Clone,
LSC: LevelSizeChooser,
CSB: CollisionSolverBuilder + IsLossless,
BS: BuildStatsCollector,
BC: BuildCoding<C::Value, Coding = C>,
Trait Implementations§
Source§impl<C: GetSize, S> GetSize for CMap<C, S>
impl<C: GetSize, S> GetSize for CMap<C, S>
Source§const USES_DYN_MEM: bool = true
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_dyn(&self) -> usize
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§fn size_bytes_content_dyn(&self) -> usize
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
fn size_bytes(&self) -> usize
Returns approximate, total (including heap memory) number of bytes occupied by
self
.Auto Trait Implementations§
impl<C, S> Freeze for CMap<C, S>
impl<C, S> RefUnwindSafe for CMap<C, S>where
C: RefUnwindSafe,
S: RefUnwindSafe,
impl<C, S> Send for CMap<C, S>
impl<C, S> Sync for CMap<C, S>
impl<C, S> Unpin for CMap<C, S>
impl<C, S> UnwindSafe for CMap<C, S>where
C: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more