Struct orx_imp_vec::prelude::Linear
source ยท pub struct Linear { /* private fields */ }Expand description
Stategy which allows the split vector to grow linearly.
In other words, each new fragment will have equal capacity, which is equal to the capacity of the first fragment.
ยงExamples
use orx_split_vec::prelude::*;
// SplitVec<usize, Linear>
let mut vec = SplitVec::with_linear_growth(4);
assert_eq!(1, vec.fragments().len());
assert_eq!(Some(16), vec.fragments().first().map(|f| f.capacity()));
assert_eq!(Some(0), vec.fragments().first().map(|f| f.len()));
// push 160 elements
for i in 0..10 * 16 {
vec.push(i);
}
assert_eq!(10, vec.fragments().len());
for fragment in vec.fragments() {
assert_eq!(16, fragment.len());
assert_eq!(16, fragment.capacity());
}
// push the 161-st element
vec.push(42);
assert_eq!(11, vec.fragments().len());
assert_eq!(Some(16), vec.fragments().last().map(|f| f.capacity()));
assert_eq!(Some(1), vec.fragments().last().map(|f| f.len()));Trait Implementationsยง
sourceยงimpl Growth for Linear
impl Growth for Linear
sourceยงfn new_fragment_capacity<T>(&self, _fragments: &[Fragment<T>]) -> usize
fn new_fragment_capacity<T>(&self, _fragments: &[Fragment<T>]) -> usize
Given that the split vector contains the given
fragments,
returns the capacity of the next fragment.sourceยงimpl PartialEq for Linear
impl PartialEq for Linear
impl StructuralPartialEq for Linear
Auto Trait Implementationsยง
impl RefUnwindSafe for Linear
impl Send for Linear
impl Sync for Linear
impl Unpin for Linear
impl UnwindSafe for Linear
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