pub struct AttributeBuffer { /* private fields */ }Implementations§
Source§impl AttributeBuffer
impl AttributeBuffer
pub fn new(component_type: ComponentDataType, num_components: usize) -> Self
pub fn get<Data, const N: usize>(&self, idx: AttributeValueIdx) -> Data
Sourcepub unsafe fn get_unchecked<Data, const N: usize>(
&self,
idx: AttributeValueIdx,
) -> Data
pub unsafe fn get_unchecked<Data, const N: usize>( &self, idx: AttributeValueIdx, ) -> Data
§Safety:
Two checks are ignored in this function: (1) ‘std::mem::size_of::()==component.size() * num_components’, and (2) idx < self.len
pub fn get_component_type(&self) -> ComponentDataType
pub fn set_component_type(&mut self, component_type: ComponentDataType)
pub fn set_num_components(&mut self, num_components: usize)
pub fn get_num_components(&self) -> usize
pub fn push<Data, const N: usize>(&mut self, data: Data)
Sourcepub unsafe fn push_type_unchecked<Data, const N: usize>(&mut self, data: Data)
pub unsafe fn push_type_unchecked<Data, const N: usize>(&mut self, data: Data)
pushes a value into the buffer without checking the type and the number of components.
§Safety
This function is unsafe because it does not check the type and the number of components of the data.
Sourcepub unsafe fn as_slice<Data>(&self) -> &[Data]
pub unsafe fn as_slice<Data>(&self) -> &[Data]
Returns a slice of all the values in the buffer casted to the static type Data.
§Safety
This function assumes that the buffer’s data is properly aligned and matches the type Data.
Sourcepub unsafe fn as_slice_mut<Data>(&mut self) -> &mut [Data]
pub unsafe fn as_slice_mut<Data>(&mut self) -> &mut [Data]
Returns the mutable slice of all the values in the buffer casted to the static type Data.
§Safety
This function assumes that the buffer’s data is properly aligned and matches the type Data.
pub unsafe fn into_vec<Data, const N: usize>(self) -> Vec<Data>where
Data: Vector<N>,
pub unsafe fn into_vec_unchecked<Data, const N: usize>(self) -> Vec<Data>where
Data: Vector<N>,
Sourcepub fn as_slice_u8(&self) -> &[u8] ⓘ
pub fn as_slice_u8(&self) -> &[u8] ⓘ
Returns a slice of all the values in the buffer casted to the static type u8.
Sourcepub unsafe fn permute_unchecked(&mut self, permutation: &[usize])
pub unsafe fn permute_unchecked(&mut self, permutation: &[usize])
#Safety This function assumes that the permutation is welll-defined in the sense that (1) it has the same length as the buffer, (2) its elements are distinct.
Sourcepub unsafe fn swap_unchecked(&mut self, i: usize, j: usize)
pub unsafe fn swap_unchecked(&mut self, i: usize, j: usize)
Swaps the elements at indices i and j in the buffer without checking the bounds.
§Safety
This function assumes that i and j are within the bounds of the buffer.
pub fn from_vec<Data, const N: usize>(data: Vec<Data>) -> Self
pub fn remove<Data, const N: usize>(&mut self, i: usize)
Sourcepub fn retain_indices(&mut self, keep_indices: &[usize])
pub fn retain_indices(&mut self, keep_indices: &[usize])
Retains only the elements at the given sorted indices, compacting the buffer in O(n).
keep_indices must be sorted in ascending order and contain valid indices < self.len.