Struct swh_graph::collections::PathStack
source · pub struct PathStack(/* private fields */);
Expand description
A stack that stores sequences of FilenameId
as a single array
Internally, it is a flattened array of paths. Each sequence is made of parts represented by an id, and sequences are separated by PATH_SEPARATOR.
Parts are in the reverse order of insertion, to avoid lazily popping without peeking.
use swh_graph::collections::PathStack;
use swh_graph::labels::FilenameId;
let path1 = [FilenameId(0), FilenameId(10)];
let path2 = [FilenameId(1)];
let mut stack = PathStack::new();
stack.push(path1);
stack.push(path2);
assert_eq!(stack.pop().unwrap().collect::<Vec<_>>(), path2);
assert_eq!(stack.pop().unwrap().collect::<Vec<_>>(), path1);
assert!(stack.pop().is_none());
Implementations§
source§impl PathStack
impl PathStack
pub fn new() -> PathStack
sourcepub fn with_capacity(capacity: usize) -> PathStack
pub fn with_capacity(capacity: usize) -> PathStack
Creates a new empty PathStack
pre-allocated for this many paths plus path parts.
sourcepub fn push<Iter: IntoIterator<Item = FilenameId>>(&mut self, path: Iter)where
<Iter as IntoIterator>::IntoIter: DoubleEndedIterator,
pub fn push<Iter: IntoIterator<Item = FilenameId>>(&mut self, path: Iter)where <Iter as IntoIterator>::IntoIter: DoubleEndedIterator,
Adds a path to this stack
Panics
If any of the FilenameId
path parts was manually built from u64::MAX
.
sourcepub fn push_filename(&mut self, item: FilenameId)
pub fn push_filename(&mut self, item: FilenameId)
Adds a path part to the last path on this stack
Panics
If the FilenameId
path parts was manually built from u64::MAX
.
sourcepub fn pop(&mut self) -> Option<PopPathStack<'_>>
pub fn pop(&mut self) -> Option<PopPathStack<'_>>
Removes the last path of this stack
Returns an iterator that pops parts from the part as the iterator is consumed. It is safe to drop the iterator without consuming it.
Trait Implementations§
source§impl PartialEq for PathStack
impl PartialEq for PathStack
impl Eq for PathStack
impl StructuralEq for PathStack
impl StructuralPartialEq for PathStack
Auto Trait Implementations§
impl RefUnwindSafe for PathStack
impl Send for PathStack
impl Sync for PathStack
impl Unpin for PathStack
impl UnwindSafe for PathStack
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
§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere U: CastableFrom<T>,
§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere U: DowncastableFrom<T>,
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere T: ?Sized,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.