pub struct ResizingBag<T> { /* private fields */ }Expand description
A bag (or multiset) of generic items.
It supports insertion and iterating over the items in arbitrary order.
This implementation uses an SVec. Substituting std::vec::Vec for SVec also works.
ResizingBag is similar to algs4 Java version ResizingArrayBag. See crate::LinkedBag for
a version that uses a linked list.
The add, is_empty, and size operations take constant time. Iteration takes time
proportional to the number of items.
For additional documentation, see Section 1.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
Implementations§
Source§impl<T> ResizingBag<T>
impl<T> ResizingBag<T>
Sourcepub fn iter(&self) -> ResizingBagIter<'_, T> ⓘ
pub fn iter(&self) -> ResizingBagIter<'_, T> ⓘ
Returns an iterator that iterates over the items in this bag in arbitrary order.
Trait Implementations§
Source§impl<T: Clone> Clone for ResizingBag<T>
impl<T: Clone> Clone for ResizingBag<T>
Source§fn clone(&self) -> ResizingBag<T>
fn clone(&self) -> ResizingBag<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<T> Freeze for ResizingBag<T>
impl<T> RefUnwindSafe for ResizingBag<T>where
T: RefUnwindSafe,
impl<T> Send for ResizingBag<T>where
T: Send,
impl<T> Sync for ResizingBag<T>where
T: Sync,
impl<T> Unpin for ResizingBag<T>
impl<T> UnwindSafe for ResizingBag<T>where
T: RefUnwindSafe,
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