pub struct BTreeVec<T, const B: usize = 12_usize> { /* private fields */ }Expand description
A growable array (vector) implemented as a B+ tree.
Provides non-amortized O(log n) random accesses, insertions, and removals, and O(n) iteration.
B is the branching factor. It must be at least 3. The standard library
uses a value of 6 for its B-tree structures. Larger values are better when
T is smaller.
Implementations
sourceimpl<T> BTreeVec<T>
impl<T> BTreeVec<T>
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BTreeVec. Note that this function is implemented
only for the default value of B; see Self::create for an
equivalent that works with all values of B.
sourceimpl<T, const B: usize> BTreeVec<T, B>
impl<T, const B: usize> BTreeVec<T, B>
sourcepub fn create() -> Self
pub fn create() -> Self
Creates a new BTreeVec. This function exists because
BTreeVec::new is implemented only for the default value of B.
sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Gets the item at index, or None if no such item exists.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut T>
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
Gets a mutable reference to the item at index, or None if no such
item exists.
sourcepub fn first(&self) -> Option<&T>
pub fn first(&self) -> Option<&T>
Gets the first item in the vector, or None if the vector is empty.
sourcepub fn first_mut(&mut self) -> Option<&mut T>
pub fn first_mut(&mut self) -> Option<&mut T>
Gets a mutable reference to the first item in the vector, or None
if the vector is empty.
sourcepub fn last(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
Gets the last item in the vector, or None if the vector is empty.
sourcepub fn last_mut(&mut self) -> Option<&mut T>
pub fn last_mut(&mut self) -> Option<&mut T>
Gets a mutable reference to the last item in the vector, or None if
the vector is empty.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes and returns the last item in the vector, or None if the
vector is empty.
Trait Implementations
sourceimpl<'a, T, const B: usize> IntoIterator for &'a BTreeVec<T, B>
impl<'a, T, const B: usize> IntoIterator for &'a BTreeVec<T, B>
sourceimpl<'a, T, const B: usize> IntoIterator for &'a mut BTreeVec<T, B>
impl<'a, T, const B: usize> IntoIterator for &'a mut BTreeVec<T, B>
sourceimpl<T, const B: usize> IntoIterator for BTreeVec<T, B>
impl<T, const B: usize> IntoIterator for BTreeVec<T, B>
impl<T, const B: usize> Send for BTreeVec<T, B>
impl<T, const B: usize> Sync for BTreeVec<T, B>
Auto Trait Implementations
impl<T, const B: usize> RefUnwindSafe for BTreeVec<T, B> where
T: RefUnwindSafe,
impl<T, const B: usize> Unpin for BTreeVec<T, B> where
T: Unpin,
impl<T, const B: usize> UnwindSafe for BTreeVec<T, B> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more