pub struct BoundedVector<T>where
T: HeapSpace,{ /* private fields */ }
Expand description
A contiguous but non-growable array type, using Vector
This exposes a subset of the Vector
API (and thus essentially behaves
like a std::vec::Vec
). Notably, it does not provide functions that grow the
capacity of the vector.
A BoundedVector
can be used as a stack with a known maximum size.
Implementations§
Source§impl<T: HeapSpace> BoundedVector<T>
impl<T: HeapSpace> BoundedVector<T>
Sourcepub fn with_capacity(capacity: usize) -> BoundedVector<T>
pub fn with_capacity(capacity: usize) -> BoundedVector<T>
See Vec::with_capacity()
.
Sourcepub fn push(&mut self, value: T)
pub fn push(&mut self, value: T)
Pushes a value, increasing the vector’s length by one.
Note that unlike [
Vec::push()`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.push)
this does not grow the vector if it is full.
§Panics
Panics if there is no space for the new element.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
See Vec::len()
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
See Vec::is_empty()
.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
See Vec::capacity()
.
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
See Vec::pop()
.
Sourcepub fn first(&self) -> &T
pub fn first(&self) -> &T
See Vec::first()
.
Sourcepub fn last(&self) -> &T
pub fn last(&self) -> &T
See Vec::last()
.
Sourcepub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
See Vec::iter()
.
Sourcepub fn as_ptr(&mut self) -> *const T
pub fn as_ptr(&mut self) -> *const T
See Vec::as_ptr()
.
Sourcepub fn mut_ptr(&mut self) -> *mut T
pub fn mut_ptr(&mut self) -> *mut T
See Vec::mut_ptr()
.
Sourcepub fn truncate(&mut self, new_length: usize)
pub fn truncate(&mut self, new_length: usize)
See Vec::truncate()
.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
See Vec::clear()
.
Source§impl<T: HeapSpace + Clone + Default> BoundedVector<T>
impl<T: HeapSpace + Clone + Default> BoundedVector<T>
Sourcepub fn resize(&mut self, new_length: usize)
pub fn resize(&mut self, new_length: usize)
See Vec::resize()
.
Source§impl<T: HeapSpace + Ord> BoundedVector<T>
impl<T: HeapSpace + Ord> BoundedVector<T>
Sourcepub fn sort_unstable(&mut self)
pub fn sort_unstable(&mut self)
See Vec::sort_unstable()
.
Source§impl<T: HeapSpace> BoundedVector<T>
impl<T: HeapSpace> BoundedVector<T>
Sourcepub fn sort_unstable_by_key<F, K>(&mut self, f: F)
pub fn sort_unstable_by_key<F, K>(&mut self, f: F)
Trait Implementations§
Source§impl<T> Clone for BoundedVector<T>
impl<T> Clone for BoundedVector<T>
Source§fn clone(&self) -> BoundedVector<T>
fn clone(&self) -> BoundedVector<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more