pub struct Fragment<T> { /* private fields */ }Expand description
A contiguous fragment of the split vector.
Suppose a split vector contains 10 integers from 0 to 9. Depending on the growth strategy of the split vector, this data might be stored in 3 contiguous fragments, say [0, 1, 2, 3], [4, 5, 6, 7] and [8, 9].
Implementations§
Source§impl<T> Fragment<T>
impl<T> Fragment<T>
Sourcepub fn new(capacity: usize, data: Vec<T>) -> Self
pub fn new(capacity: usize, data: Vec<T>) -> Self
Creates a fragment from data with the target logical capacity.
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consumes the fragment and returns the inner vector.
Sourcepub fn has_capacity_for_one(&self) -> bool
pub fn has_capacity_for_one(&self) -> bool
Returns whether the fragment has room to push a new item or not.
Sourcepub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
pub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
Binary-searches initialized elements with a comparator.
Sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Returns a shared reference to the element at index, if present.
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> &T
pub unsafe fn get_unchecked(&self, index: usize) -> &T
Returns a shared reference to the element at index without bounds checks.
§Safety
Caller must ensure index < self.len().
Sourcepub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<T>
§SAFETY
Obtained reference to the vector can be used to change the length of the vector by adding or removing elements; however, it must not change the capacity and underlying allocation of the vector.
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Returns a mutable raw pointer to initialized elements.
Sourcepub fn extend_from_slice(&mut self, slice: &[T])where
T: Clone,
pub fn extend_from_slice(&mut self, slice: &[T])where
T: Clone,
Clones and appends all elements from slice.
Sourcepub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
Returns a mutable reference to the element at index without bounds checks.
§Safety
Caller must ensure index < self.len() and aliasing rules are respected.
Sourcepub fn insert(&mut self, index: usize, element: T)
pub fn insert(&mut self, index: usize, element: T)
Inserts element at index, shifting later elements to the right.
Sourcepub fn remove(&mut self, index: usize) -> T
pub fn remove(&mut self, index: usize) -> T
Removes and returns the element at index, shifting later elements left.