pub struct ScopeSet<T, S: BuildHasher = RandomState> { /* private fields */ }
Expand description
A layered hash set for representing the scopes of variables.
Implementations§
Source§impl<T> ScopeSet<T, RandomState>
impl<T> ScopeSet<T, RandomState>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty ScopeSet
with a default hasher and the specified capacity.
Source§impl<T, S: BuildHasher> ScopeSet<T, S>
impl<T, S: BuildHasher> ScopeSet<T, S>
Sourcepub fn with_hasher(hash_builder: S) -> Self
pub fn with_hasher(hash_builder: S) -> Self
Creates an empty ScopeSet
with the specified hasher and a default capacity.
Sourcepub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self
Creates an empty ScopeSet
with the specified capacity and hasher.
Source§impl<T, S: BuildHasher> ScopeSet<T, S>
impl<T, S: BuildHasher> ScopeSet<T, S>
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Gets the number of elements the set can hold without reallocating.
Sourcepub fn push_layer(&mut self)
pub fn push_layer(&mut self)
Adds a new, empty layer.
Computes in O(1) time.
Source§impl<T: Eq + Hash, S: BuildHasher> ScopeSet<T, S>
impl<T: Eq + Hash, S: BuildHasher> ScopeSet<T, S>
Sourcepub fn define_parent(&mut self, key: T, min_depth: usize)
pub fn define_parent(&mut self, key: T, min_depth: usize)
Adds the specified key to the layer min_depth
layers below the top layer. Saturates to base layer.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> bool
pub fn remove<Q>(&mut self, key: &Q) -> bool
Removes the specified key from the topmost layer and returns it.
Sourcepub fn contains<Q>(&self, key: &Q) -> bool
pub fn contains<Q>(&self, key: &Q) -> bool
Returns true
if any layer contains the specified key.
Computes in O(1) time.
Sourcepub fn contains_at_top<Q>(&self, key: &Q) -> bool
pub fn contains_at_top<Q>(&self, key: &Q) -> bool
Returns true
if the topmost layer contains the specified key.
Computes in O(1) time.
Sourcepub fn depth_of<Q>(&self, key: &Q) -> Option<usize>
pub fn depth_of<Q>(&self, key: &Q) -> Option<usize>
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.
Sourcepub fn depth_of_parent<Q>(&self, key: &Q, min_depth: usize) -> Option<usize>
pub fn depth_of_parent<Q>(&self, key: &Q, min_depth: usize) -> Option<usize>
Gets the depth of the specified key (i.e. how many layers down from the top that the key first appears),
but ignores a maximum number of layers from the top equal to min_depth
.
Saturates to base layer.
Returns None
if the key does not exist.
Computes in O(n) time (worst-case) in relation to layer count.
Sourcepub fn height_of<Q>(&self, key: &Q) -> Option<usize>
pub fn height_of<Q>(&self, key: &Q) -> Option<usize>
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.
Sourcepub fn height_of_parent<Q>(&self, key: &Q, min_depth: usize) -> Option<usize>
pub fn height_of_parent<Q>(&self, key: &Q, min_depth: usize) -> Option<usize>
Gets the height of the specified key (i.e. how many layers up from the bottom that the key last appears),
but ignores a maximum number of layers from the top equal to min_depth
.
A height of 0 refers to the bottom layer.
Saturates to base layer.
Returns None
if the key does not exist.
Computes in O(n) time (worst-case) in relation to layer count.