Struct pasture_core::containers::HashMapBuffer
source · pub struct HashMapBuffer { /* private fields */ }
Expand description
A point buffer that stores point data in columnar memory layout, using a HashMap<PointAttributeDefinition, Vec<u8>>
as
its underlying storage
Implementations§
source§impl HashMapBuffer
impl HashMapBuffer
sourcepub fn with_capacity(capacity: usize, point_layout: PointLayout) -> Self
pub fn with_capacity(capacity: usize, point_layout: PointLayout) -> Self
Creates a new HashMapBuffer
with the given capacity
and point_layout
. It preallocates enough memory to store
at least capacity
points
sourcepub fn begin_push_attributes(&mut self) -> HashMapBufferAttributePusher<'_>
pub fn begin_push_attributes(&mut self) -> HashMapBufferAttributePusher<'_>
Create a new helper object through which ranges of attribute data can be pushed into this buffer
sourcepub fn filter<B: for<'a> OwningBuffer<'a> + for<'a> MakeBufferFromLayout<'a>, F: Fn(usize) -> bool>(
&self,
predicate: F
) -> B
pub fn filter<B: for<'a> OwningBuffer<'a> + for<'a> MakeBufferFromLayout<'a>, F: Fn(usize) -> bool>( &self, predicate: F ) -> B
Like Iterator::filter
, but filters into a point buffer of type B
sourcepub fn filter_into<B: for<'a> BorrowedMutBuffer<'a>, F: Fn(usize) -> bool>(
&self,
buffer: &mut B,
predicate: F,
num_matches_hint: Option<usize>
)
pub fn filter_into<B: for<'a> BorrowedMutBuffer<'a>, F: Fn(usize) -> bool>( &self, buffer: &mut B, predicate: F, num_matches_hint: Option<usize> )
Like filter
, but writes the filtered points into the given buffer
panics
If buffer.len()
is less than the number of matching points according to predicate
If the PointLayout
of buffer
does not match the PointLayout
of self
Trait Implementations§
source§impl<'a> BorrowedBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
impl<'a> BorrowedBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
source§fn point_layout(&self) -> &PointLayout
fn point_layout(&self) -> &PointLayout
Returns the
PointLayout
of this buffer. The PointLayout
describes the structure of a single
point at runtime. Read moresource§fn get_attribute(
&self,
attribute: &PointAttributeDefinition,
index: usize,
data: &mut [u8]
)
fn get_attribute( &self, attribute: &PointAttributeDefinition, index: usize, data: &mut [u8] )
source§unsafe fn get_attribute_unchecked(
&self,
attribute_member: &PointAttributeMember,
index: usize,
data: &mut [u8]
)
unsafe fn get_attribute_unchecked( &self, attribute_member: &PointAttributeMember, index: usize, data: &mut [u8] )
Like
get_attribute
, but performs no check whether the attribute actually is part of this buffers PointLayout
or not. Because of this, this function accepts a PointAttributeMember
instead of a PointAttributeDefinition
,
and this PointAttributeMember
must come from the PointLayout
of this buffer! The benefit over get_attribute
is that this function skips the include checks and thus will be faster if you repeatedly want to get data for a
single attribute Read moresource§fn as_columnar(&self) -> Option<&dyn ColumnarBuffer<'a>>
fn as_columnar(&self) -> Option<&dyn ColumnarBuffer<'a>>
Try to get a reference to
self
as a ColumnarBuffer
. Returns None
if self
does not
implement ColumnarBuffer
source§fn get_attribute_range(
&self,
attribute: &PointAttributeDefinition,
point_range: Range<usize>,
data: &mut [u8]
)
fn get_attribute_range( &self, attribute: &PointAttributeDefinition, point_range: Range<usize>, data: &mut [u8] )
Writes the data for the given
attribute
of the given range of points into data
. The attribute data will
be tightly packed in data
, irregardless of the memory layout of this buffer. The attribute values might not
be correctly aligned, if the alignment requirement of attribute.datatype()
is larger than the size of the
attribute. All of the built-in attributes in pasture have alignments that are less than or equal to their size,
so for built-in attributes you can assume that the attributes in data
are correctly aligned. Read moresource§fn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
fn view<'b, T: PointType>(&'b self) -> PointView<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
Get a strongly typed view of the point data of this buffer Read more
source§fn view_attribute<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition
) -> AttributeView<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
fn view_attribute<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition
) -> AttributeView<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
Gets a strongly typed view of the
attribute
of all points in this buffer Read moresource§fn view_attribute_with_conversion<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition
) -> Result<AttributeViewConverting<'a, 'b, Self, T>>where
Self: Sized,
'a: 'b,
fn view_attribute_with_conversion<'b, T: PrimitiveType>(
&'b self,
attribute: &PointAttributeDefinition
) -> Result<AttributeViewConverting<'a, 'b, Self, T>>where
Self: Sized,
'a: 'b,
Like
the
view_attribute
, but allows T::data_type()
to be different from the data type ofthe
attribute
within this buffer. Read moresource§fn as_interleaved(&self) -> Option<&dyn InterleavedBuffer<'a>>
fn as_interleaved(&self) -> Option<&dyn InterleavedBuffer<'a>>
Try to get a reference to
self
as an InterleavedBuffer
. Returns None
if self
does not
implement InterleavedBuffer
source§impl<'a> BorrowedMutBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
impl<'a> BorrowedMutBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
source§unsafe fn set_point(&mut self, index: usize, point_data: &[u8])
unsafe fn set_point(&mut self, index: usize, point_data: &[u8])
Sets the data for the point at the given
index
Read moresource§unsafe fn set_attribute(
&mut self,
attribute: &PointAttributeDefinition,
index: usize,
attribute_data: &[u8]
)
unsafe fn set_attribute( &mut self, attribute: &PointAttributeDefinition, index: usize, attribute_data: &[u8] )
source§fn swap(&mut self, from_index: usize, to_index: usize)
fn swap(&mut self, from_index: usize, to_index: usize)
Swaps the two points at
from_index
and to_index
. Implementations should allow the case where from_index == to_index
Read moresource§unsafe fn set_point_range(
&mut self,
point_range: Range<usize>,
point_data: &[u8]
)
unsafe fn set_point_range( &mut self, point_range: Range<usize>, point_data: &[u8] )
Sets the data for the given range of points. This function will generally be more efficient than calling [
set_point
]
multiple times, as [set_point
] performs size and index checks on every call, whereas this function can perform them
only once. Assumes that the point_data
is tightly packed, i.e. stored in an interleaved format with point alignment
of 1
. Read moresource§unsafe fn set_attribute_range(
&mut self,
attribute: &PointAttributeDefinition,
point_range: Range<usize>,
attribute_data: &[u8]
)
unsafe fn set_attribute_range( &mut self, attribute: &PointAttributeDefinition, point_range: Range<usize>, attribute_data: &[u8] )
Sets the data for the given
attribute
for all points in point_range
. This function will generally be more efficient
than calling [set_attribute
] multiple times, as [set_attribute
] has to perform type and bounds checks on each call. Read moresource§fn as_columnar_mut(&mut self) -> Option<&mut dyn ColumnarBufferMut<'a>>
fn as_columnar_mut(&mut self) -> Option<&mut dyn ColumnarBufferMut<'a>>
Try to get a mutable reference to
self
as a ColumnarBufferMut
. Returns None
if self
does not
implement ColumnarBufferMut
source§fn transform_attribute<'b, T: PrimitiveType, F: Fn(usize, T) -> T>(
&'b mut self,
attribute: &PointAttributeDefinition,
func: F
)where
Self: Sized,
'a: 'b,
fn transform_attribute<'b, T: PrimitiveType, F: Fn(usize, T) -> T>(
&'b mut self,
attribute: &PointAttributeDefinition,
func: F
)where
Self: Sized,
'a: 'b,
Apply a transformation function to the given
attribute
of all points within this buffer. This function is
helpful if you want to modify a single attribute of a buffer in-place and works for buffers of all memory
layouts. For columnar buffers, prefer using get_attribute_range_mut
to modify attribute data in-place. Read moresource§fn view_mut<'b, T: PointType>(&'b mut self) -> PointViewMut<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
fn view_mut<'b, T: PointType>(&'b mut self) -> PointViewMut<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
Get a strongly typed view of the point data of this buffer. This view allows mutating the point data! Read more
source§fn view_attribute_mut<'b, T: PrimitiveType>(
&'b mut self,
attribute: &PointAttributeDefinition
) -> AttributeViewMut<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
fn view_attribute_mut<'b, T: PrimitiveType>(
&'b mut self,
attribute: &PointAttributeDefinition
) -> AttributeViewMut<'a, 'b, Self, T>where
Self: Sized,
'a: 'b,
Get a strongly typed view of the
attribute
of all points in this buffer. This view allows mutating
the attribute data! Read moresource§fn as_interleaved_mut(&mut self) -> Option<&mut dyn InterleavedBufferMut<'a>>
fn as_interleaved_mut(&mut self) -> Option<&mut dyn InterleavedBufferMut<'a>>
Try to get a mutable reference to
self
as an InterleavedBufferMut
. Returns None
if self
does not
implement InterleavedBufferMut
source§impl Clone for HashMapBuffer
impl Clone for HashMapBuffer
source§fn clone(&self) -> HashMapBuffer
fn clone(&self) -> HashMapBuffer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a> ColumnarBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
impl<'a> ColumnarBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
source§fn get_attribute_ref<'b>(
&'b self,
attribute: &PointAttributeDefinition,
index: usize
) -> &'b [u8] ⓘwhere
'a: 'b,
fn get_attribute_ref<'b>(
&'b self,
attribute: &PointAttributeDefinition,
index: usize
) -> &'b [u8] ⓘwhere
'a: 'b,
Get an immutable slice to the memory of the given
attribute
for the point at index
. See InterleavedBuffer::get_point_ref
for an explanation of the lifetime bounds. Read moresource§fn get_attribute_range_ref<'b>(
&'b self,
attribute: &PointAttributeDefinition,
range: Range<usize>
) -> &'b [u8] ⓘwhere
'a: 'b,
fn get_attribute_range_ref<'b>(
&'b self,
attribute: &PointAttributeDefinition,
range: Range<usize>
) -> &'b [u8] ⓘwhere
'a: 'b,
source§fn view_raw_attribute<'b>(
&'b self,
attribute: &PointAttributeMember
) -> RawAttributeView<'b>where
'a: 'b,
fn view_raw_attribute<'b>(
&'b self,
attribute: &PointAttributeMember
) -> RawAttributeView<'b>where
'a: 'b,
Get a raw view over the given
attribute
from this point buffer. Unlike the typed view that view_attribute
returns, this view dereferences to byte slices, but it is potentially more efficient to use than calling
get_attribute
repeatedlysource§impl<'a> ColumnarBufferMut<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
impl<'a> ColumnarBufferMut<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
source§fn get_attribute_mut<'b>(
&'b mut self,
attribute: &PointAttributeDefinition,
index: usize
) -> &'b mut [u8] ⓘwhere
'a: 'b,
fn get_attribute_mut<'b>(
&'b mut self,
attribute: &PointAttributeDefinition,
index: usize
) -> &'b mut [u8] ⓘwhere
'a: 'b,
Get a mutable slice to the memory of the given
attribute
for the point at index
. This is the mutable
version of ColumnarBuffer::get_attribute_ref
Read moresource§fn get_attribute_range_mut<'b>(
&'b mut self,
attribute: &PointAttributeDefinition,
range: Range<usize>
) -> &'b mut [u8] ⓘwhere
'a: 'b,
fn get_attribute_range_mut<'b>(
&'b mut self,
attribute: &PointAttributeDefinition,
range: Range<usize>
) -> &'b mut [u8] ⓘwhere
'a: 'b,
Get a mutable slice to the memory for the
attribute
of the given range
of points. This is the mutable
version of ColumnarBuffer::get_attribute_range_ref
Read moresource§fn view_raw_attribute_mut<'b>(
&'b mut self,
attribute: &PointAttributeMember
) -> RawAttributeViewMut<'b>where
'a: 'b,
fn view_raw_attribute_mut<'b>(
&'b mut self,
attribute: &PointAttributeMember
) -> RawAttributeViewMut<'b>where
'a: 'b,
Like
view_raw_attribute
, but returns mutable byte slices of the attribute datasource§impl Debug for HashMapBuffer
impl Debug for HashMapBuffer
source§impl<T: PointType> FromIterator<T> for HashMapBuffer
impl<T: PointType> FromIterator<T> for HashMapBuffer
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
source§impl<'a> MakeBufferFromLayout<'a> for HashMapBuffer
impl<'a> MakeBufferFromLayout<'a> for HashMapBuffer
source§fn new_from_layout(point_layout: PointLayout) -> Self
fn new_from_layout(point_layout: PointLayout) -> Self
Creates a new empty buffer from the given
PointLayout
source§impl<'a> OwningBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
impl<'a> OwningBuffer<'a> for HashMapBufferwhere
HashMapBuffer: 'a,
source§unsafe fn push_points(&mut self, point_bytes: &[u8])
unsafe fn push_points(&mut self, point_bytes: &[u8])
Push the raw memory for a range of points into this buffer. Works similar to
Vec::push
Read moresource§fn resize(&mut self, count: usize)
fn resize(&mut self, count: usize)
Resize this buffer to contain exactly
count
points. If count
is less than self.len()
, point data
is removed, if count
is greater than self.len()
new points are default-constructed (i.e. zero-initialized).source§fn clear(&mut self)
fn clear(&mut self)
Clears the contents of this buffer, removing all point data and setting the length to
0
source§fn append_interleaved<'b, B: InterleavedBuffer<'b>>(&mut self, other: &B)
fn append_interleaved<'b, B: InterleavedBuffer<'b>>(&mut self, other: &B)
Appends data from the given interleaved buffer to the end of this buffer Read more
source§fn append_columnar<'b, B: ColumnarBuffer<'b>>(&mut self, other: &B)
fn append_columnar<'b, B: ColumnarBuffer<'b>>(&mut self, other: &B)
Appends data from the given columnar buffer to the end of this buffer Read more
source§fn append<'b, B: BorrowedBuffer<'b>>(&mut self, other: &B)
fn append<'b, B: BorrowedBuffer<'b>>(&mut self, other: &B)
Appends data from the given buffer to the end of this buffer. Makes no assumptions about the memory
layout of
other
. If you know the memory layout of other
, consider using append_interleaved
or
append_columnar
instead, as these will give better performance. Read moresource§impl PartialEq for HashMapBuffer
impl PartialEq for HashMapBuffer
source§fn eq(&self, other: &HashMapBuffer) -> bool
fn eq(&self, other: &HashMapBuffer) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<'a> SliceBuffer<'a> for HashMapBufferwhere
Self: 'a,
impl<'a> SliceBuffer<'a> for HashMapBufferwhere
Self: 'a,
source§impl<'a> SliceBufferMut<'a> for HashMapBuffer
impl<'a> SliceBufferMut<'a> for HashMapBuffer
type SliceTypeMut = BufferSliceColumnarMut<'a, HashMapBuffer>
impl Eq for HashMapBuffer
impl StructuralEq for HashMapBuffer
impl StructuralPartialEq for HashMapBuffer
Auto Trait Implementations§
impl RefUnwindSafe for HashMapBuffer
impl Send for HashMapBuffer
impl Sync for HashMapBuffer
impl Unpin for HashMapBuffer
impl UnwindSafe for HashMapBuffer
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.