[][src]Struct hayami::SymbolTable

pub struct SymbolTable<K: Hash + Eq, V, S: BuildHasher = RandomState> { /* fields omitted */ }

A simple, generic symbol table.

Behaves like a stack of HashMaps, where you can only insert symbols into the top map with insert. When a symbol is looked up with get, first the top map is checked, then the map under it, etc., with the first match found returned. This is implemented more efficiently using an IndexMap. get_full does the same, but returns the depth at which the symbol was found.

Implementations

impl<K: Hash + Eq, V, S: BuildHasher> SymbolTable<K, V, S> where
    IndexMap<K, Vec<(V, usize)>, S>: Default
[src]

pub fn new() -> SymbolTable<K, V, S>[src]

Create a new, empty symbol table

impl<K: Hash + Eq, V, S: BuildHasher> SymbolTable<K, V, S> where
    S: Default
[src]

pub fn with_capacity(n: usize) -> SymbolTable<K, V, S>[src]

Create a symbol table with a given capacity

impl<K: Hash + Eq, V, S: BuildHasher> SymbolTable<K, V, S>[src]

pub fn with_hasher(hash_builder: S) -> SymbolTable<K, V, S>[src]

Create a symbol table with a given hasher

pub fn with_capacity_and_hasher(
    n: usize,
    hash_builder: S
) -> SymbolTable<K, V, S>
[src]

Create a symbol table with a given capacity and hasher

pub fn depth(&self) -> usize[src]

Get the current depth

pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]

Register a given symbol at the current depth, returning the current definition at the current depth, if any.

pub fn try_insert(&mut self, key: K, value: V) -> Result<(), V>[src]

Try to register a given symbol at the current depth. Fail if the symbol is already defined

pub fn get_full<Q: ?Sized>(&self, key: &Q) -> Option<(&V, usize)> where
    Q: Hash + Equivalent<K>, 
[src]

Get the definition of a current symbol, along with its depth, if any

pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
    Q: Hash + Equivalent<K>, 
[src]

Get the definition of a symbol

pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
    Q: Hash + Equivalent<K>, 
[src]

Check whether a symbol has a definition

pub fn get_full_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<(&mut V, usize)> where
    Q: Hash + Equivalent<K>, 
[src]

Mutably get the definition of a current symbol, along with its depth, if any

pub fn try_get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
    Q: Hash + Equivalent<K>, 
[src]

Try to mutably get the definition of a current symbol at the current depth

pub fn jump(&mut self, depth: usize)[src]

Get the mutable definition of a current symbol, along with its depth, if any Jump to a given depth, removing obsolete definitions. Return the number of keys and definitions removed, as well as keys touched, if any.

pub fn push(&mut self)[src]

Add a level of depth

pub fn popn(&mut self, n: usize)[src]

Pop up to n levels of depth.

pub fn pop(&mut self)[src]

Try to remove a level of depth. Does nothing if depth = 0

pub fn is_empty(&self) -> bool[src]

Check whether a symbol table is empty

pub fn reserve(&mut self, additional: usize)[src]

Reserve space for at least additional symbols in this symbol table

pub fn capacity(&self) -> usize[src]

Get the capacity of this symbol table

Trait Implementations

impl<K: Clone + Hash + Eq, V: Clone, S: Clone + BuildHasher> Clone for SymbolTable<K, V, S>[src]

impl<K: Hash + Eq + Debug, V: Debug, S: BuildHasher> Debug for SymbolTable<K, V, S>[src]

impl<K: Hash + Eq, V, S: BuildHasher> Default for SymbolTable<K, V, S> where
    IndexMap<K, Vec<(V, usize)>, S>: Default
[src]

impl<K: Eq + Hash, V: Eq, S: Eq + BuildHasher> Eq for SymbolTable<K, V, S>[src]

impl<K: PartialEq + Hash + Eq, V: PartialEq, S: PartialEq + BuildHasher> PartialEq<SymbolTable<K, V, S>> for SymbolTable<K, V, S>[src]

impl<K: Hash + Eq, V, S: BuildHasher> StructuralEq for SymbolTable<K, V, S>[src]

impl<K: Hash + Eq, V, S: BuildHasher> StructuralPartialEq for SymbolTable<K, V, S>[src]

Auto Trait Implementations

impl<K, V, S> RefUnwindSafe for SymbolTable<K, V, S> where
    K: RefUnwindSafe,
    S: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V, S> Send for SymbolTable<K, V, S> where
    K: Send,
    S: Send,
    V: Send

impl<K, V, S> Sync for SymbolTable<K, V, S> where
    K: Sync,
    S: Sync,
    V: Sync

impl<K, V, S> Unpin for SymbolTable<K, V, S> where
    K: Unpin,
    S: Unpin,
    V: Unpin

impl<K, V, S> UnwindSafe for SymbolTable<K, V, S> where
    K: UnwindSafe,
    S: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.