pub struct CodeDictionary<T: Eq + Hash> { /* private fields */ }Available on crate feature
std only.Expand description
Simple auto-incrementing dictionary indexed by hash value. Creates new codes for new values when first seen. Increments in order of query.
Implementations§
Source§impl<T: Eq + Hash + Default> CodeDictionary<T>
impl<T: Eq + Hash + Default> CodeDictionary<T>
pub fn new() -> CodeDictionary<T>
Source§impl<T: Eq + Hash + Clone> CodeDictionary<T>
impl<T: Eq + Hash + Clone> CodeDictionary<T>
Sourcepub fn lookup_value(&self, value: &T) -> Option<u32>
pub fn lookup_value(&self, value: &T) -> Option<u32>
Looks up a code for a specific value
Sourcepub fn get_code(&mut self, value: &T) -> (bool, u32)
pub fn get_code(&mut self, value: &T) -> (bool, u32)
Returns the code for the specified value and if a new code was generated for the value (first time seeing the value).
pub fn read_code<F: FnOnce() -> Result<T, E>, E>( &mut self, code: u32, value_producer: F, ) -> Result<T, E>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CodeDictionary<T>
impl<T> RefUnwindSafe for CodeDictionary<T>where
T: RefUnwindSafe,
impl<T> Send for CodeDictionary<T>where
T: Send,
impl<T> Sync for CodeDictionary<T>where
T: Sync,
impl<T> Unpin for CodeDictionary<T>where
T: Unpin,
impl<T> UnwindSafe for CodeDictionary<T>where
T: 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