pub struct FrequencyPool { /* private fields */ }Expand description
A string pool that tracks how often each string is interned.
Implementations§
Source§impl FrequencyPool
impl FrequencyPool
Sourcepub fn intern(&mut self, s: &str) -> InternedString
pub fn intern(&mut self, s: &str) -> InternedString
Intern a string and increment its frequency.
Sourcepub fn frequency(&self, id: InternedString) -> u64
pub fn frequency(&self, id: InternedString) -> u64
Get the frequency of an interned string.
Sourcepub fn top_k(&self, k: usize) -> Vec<(InternedString, u64)>
pub fn top_k(&self, k: usize) -> Vec<(InternedString, u64)>
Get the top-k most frequent strings.
Sourcepub fn resolve(&self, id: InternedString) -> Option<&str>
pub fn resolve(&self, id: InternedString) -> Option<&str>
Resolve an interned string.
Sourcepub fn pool(&self) -> &StringPool
pub fn pool(&self) -> &StringPool
Inner pool reference.
Sourcepub fn total_calls(&self) -> u64
pub fn total_calls(&self) -> u64
Total number of intern calls (sum of all frequencies).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrequencyPool
impl RefUnwindSafe for FrequencyPool
impl Send for FrequencyPool
impl Sync for FrequencyPool
impl Unpin for FrequencyPool
impl UnsafeUnpin for FrequencyPool
impl UnwindSafe for FrequencyPool
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