Trait orx_split_vec::Growth
source · pub trait Growth: Clone {
// Required method
fn new_fragment_capacity<T>(&self, fragments: &[Fragment<T>]) -> usize;
// Provided methods
fn get_fragment_and_inner_indices<T>(
&self,
_vec_len: usize,
fragments: &[Fragment<T>],
element_index: usize
) -> Option<(usize, usize)> { ... }
unsafe fn get_ptr_mut<T>(
&self,
fragments: &mut [Fragment<T>],
index: usize
) -> Option<*mut T> { ... }
}Expand description
Growth strategy of a split vector.
Required Methods§
sourcefn 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.
Provided Methods§
sourcefn get_fragment_and_inner_indices<T>(
&self,
_vec_len: usize,
fragments: &[Fragment<T>],
element_index: usize
) -> Option<(usize, usize)>
fn get_fragment_and_inner_indices<T>( &self, _vec_len: usize, fragments: &[Fragment<T>], element_index: usize ) -> Option<(usize, usize)>
O(fragments.len()) Returns the location of the element with the given element_index on the split vector as a tuple of (fragment-index, index-within-fragment).
Returns None if the element index is out of bounds.
sourceunsafe fn get_ptr_mut<T>(
&self,
fragments: &mut [Fragment<T>],
index: usize
) -> Option<*mut T>
unsafe fn get_ptr_mut<T>( &self, fragments: &mut [Fragment<T>], index: usize ) -> Option<*mut T>
O(fragments.len()) Returns a mutable reference to the index-th element of the split vector of the fragments.
Returns None if index-th position does not belong to the split vector; i.e., if index is out of cumulative capacity of fragments.
§Safety
This method allows to write to a memory which is greater than the vector’s length. On the other hand, it will never return a pointer to a memory location that the vector does not own.