pub trait StringTable<'a, Key: PartialOrd + Copy> {
    // Required methods
    fn add(&mut self, value: &str) -> Key;
    fn remove(&mut self, key: Key);
    fn get(&self, key: Key) -> Option<&Cow<'a, str>>;
    fn len(&self) -> usize;
    fn contains(&self, value: &str) -> Option<u64>;
    fn hash(&self, value: &str) -> u64;
}
Expand description

Trait defining the basic operations required by a string table

Required Methods§

source

fn add(&mut self, value: &str) -> Key

Add a new value to the string table. Returns the u32 hash value of the entry. If the entry already exists within the table, then this operation is idempotent, but the hash value is still returned.

source

fn remove(&mut self, key: Key)

Attempts to remove a given value from the table.

source

fn get(&self, key: Key) -> Option<&Cow<'a, str>>

Attempts to retrieve a given value from the table.

source

fn len(&self) -> usize

The number of elements currently within the table

source

fn contains(&self, value: &str) -> Option<u64>

Check whether a given value already exists within the table. If it does, then return the hash value associated with it. If not, just return None.

source

fn hash(&self, value: &str) -> u64

Get the hash value associated with a given value. This should be consistent and repeatable between calls for the same value.

Implementors§