[][src]Struct quickscope::ScopeSet

pub struct ScopeSet<T, S: BuildHasher = RandomState> { /* fields omitted */ }

A layered hash set for representing the scopes of variables.

Implementations

impl<T> ScopeSet<T, RandomState>[src]

pub fn new() -> Self[src]

Creates an empty ScopeSet with a default hasher and capacity.

pub fn with_capacity(capacity: usize) -> Self[src]

Creates an empty ScopeSet with a default hasher and the specified capacity.

impl<T, S: BuildHasher> ScopeSet<T, S>[src]

pub fn with_hasher(hash_builder: S) -> Self[src]

Creates an empty ScopeSet with the specified hasher and a default capacity.

pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self[src]

Creates an empty ScopeSet with the specified capacity and hasher.

impl<T, S: BuildHasher> ScopeSet<T, S>[src]

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

Returns true is the set is empty.

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

Gets the number of elements the set can hold without reallocating.

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

Gets the number of unique keys in the set.

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

Gets the number of layers in the set.

pub fn push_layer(&mut self)[src]

Adds a new, empty layer.

Computes in O(1) time.

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

Removes the topmost layer (if it isn't the bottom layer) and all associated keys. Returns true if the layer was removed.

Computes in O(n) time in relation to the number of keys stored in the removed layer.

impl<T: Eq + Hash, S: BuildHasher> ScopeSet<T, S>[src]

pub fn clear_all(&mut self)[src]

Removes all entries and additional layers.

pub fn clear_top(&mut self)[src]

Removes all keys in the topmost layer.

pub fn define(&mut self, key: T)[src]

Adds the specified key to the topmost layer.

pub fn define_parent(&mut self, key: T, skip_count: usize)[src]

Adds the specified key to the layer skip_count layers below the top layer. Saturates to base layer.

pub fn delete(&mut self, key: T) -> bool[src]

Removes the specified key from the topmost layer.

pub fn contains<Q: ?Sized>(&self, key: &Q) -> bool where
    T: Borrow<Q>,
    Q: Eq + Hash
[src]

Returns true if any layer contains the specified key.

Computes in O(1) time.

pub fn contains_at_top<Q: ?Sized>(&self, key: &Q) -> bool where
    T: Borrow<Q>,
    Q: Eq + Hash
[src]

Returns true if the topmost layer contains the specified key. Computes in O(1) time.

pub fn depth_of<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
    T: Borrow<Q>,
    Q: Eq + Hash
[src]

Gets the depth of the specified key (i.e. how many layers down from the top that the key first appears). A depth of 0 refers to the top layer.

Returns None if the key does not exist.

Computes in O(n) time (worst-case) in relation to layer count.

pub fn height_of<Q: ?Sized>(&self, key: &Q) -> Option<usize> where
    T: Borrow<Q>,
    Q: Eq + Hash
[src]

Gets the height of the specified key (i.e. how many layers up from the bottom that the key last appears). A height of 0 refers to the bottom layer.

Returns None if the key does not exist.

Computes in O(n) time (worst-case) in relation to layer count.

pub fn iter(&self) -> impl Iterator<Item = &T>[src]

Iterates over the keys in arbitrary order.

The iterator element type is &'a T.

pub fn iter_top(&self) -> impl Iterator<Item = &T>[src]

Iterates over the top-level keys in arbitrary order.

The iterator element type is &'a T.

Trait Implementations

impl<T: Clone, S: Clone + BuildHasher> Clone for ScopeSet<T, S>[src]

impl<T, S: Default + BuildHasher> Default for ScopeSet<T, S>[src]

fn default() -> Self[src]

Creates a new ScopeSet with the default configuration.

Auto Trait Implementations

impl<T, S> RefUnwindSafe for ScopeSet<T, S> where
    S: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, S> Send for ScopeSet<T, S> where
    S: Send,
    T: Send

impl<T, S> Sync for ScopeSet<T, S> where
    S: Sync,
    T: Sync

impl<T, S> Unpin for ScopeSet<T, S> where
    S: Unpin,
    T: Unpin

impl<T, S> UnwindSafe for ScopeSet<T, S> where
    S: UnwindSafe,
    T: 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<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.