pub enum Buffer {
Booleans(Vec<bool>),
Integers(IntBuf),
Floats(FloatBuf),
Complexes(ComplexBuf),
Characters(Vec<char>),
}Expand description
Items of one element type.
Variants§
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn with_capacity(dtype: DType, capacity: usize) -> Self
pub fn with_capacity(dtype: DType, capacity: usize) -> Self
An empty buffer of dtype, with room for capacity items.
pub fn view(&self) -> View<'_>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn dtype(&self) -> DType
pub fn capacity(&self) -> usize
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve room for additional items after the current length.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
The address of the first item, for writing through, as an exported buffer may.
Sourcepub fn extend_from(&mut self, source: View<'_>, range: Range<usize>) -> bool
pub fn extend_from(&mut self, source: View<'_>, range: Range<usize>) -> bool
Copies range of source when it has this buffer’s dtype, and gives whether it could. Integers of another width don’t copy.
Source§impl Buffer
impl Buffer
Sourcepub fn nonzero(view: View<'_>) -> Vec<usize>
pub fn nonzero(view: View<'_>) -> Vec<usize>
Flattened positions whose item differs from its type’s fill (zero, false or a space).
Sourcepub fn any_fill(view: View<'_>) -> bool
pub fn any_fill(view: View<'_>) -> bool
Whether any item equals its type’s fill: zero, false or a space.
Sourcepub fn same(view: View<'_>) -> bool
pub fn same(view: View<'_>) -> bool
Whether every item has the first item’s bits, as an array of one repeated value does: 0 and ¯0 differ, and a NaN matches only a NaN with its bits. An empty view gives true.
Sourcepub fn walked(view: View<'_>, base: usize, steps: &[Steps], n: usize) -> Self
pub fn walked(view: View<'_>, base: usize, steps: &[Steps], n: usize) -> Self
Copies the first n items of a structural walk from base, using the type’s fill for missing positions and whole-slice copies for contiguous runs. n can be shorter than the walk, as it is for a view whose mapping reaches past its own items.
Sourcepub fn ordered(self, order: Option<Vec<Steps>>) -> Self
pub fn ordered(self, order: Option<Vec<Steps>>) -> Self
The items in the order that order reads them, or the buffer itself without one. Kernel::fold_read gives such an order with totals that stay in their source’s order.
Sourcepub fn copied(view: View<'_>, range: Range<usize>) -> Self
pub fn copied(view: View<'_>, range: Range<usize>) -> Self
A new buffer holding the items of view in range.
Sourcepub fn gathered<I: IndexValue>(view: View<'_>, indices: &[I]) -> Self
pub fn gathered<I: IndexValue>(view: View<'_>, indices: &[I]) -> Self
The items of view at indices, as take reads them: a negative index counts back from the end.
Sourcepub fn cast(view: View<'_>, dtype: DType) -> Result<Self, Error>
pub fn cast(view: View<'_>, dtype: DType) -> Result<Self, Error>
The items of view at dtype. Matching dtypes copy. Otherwise each item converts as Source reads it, and conversions to a narrower dtype follow these rules. A float converts to an integer by truncating toward zero. A value that doesn’t fit its target gives an Overflow error, as do NaN, infinities and anything but exactly 0 or 1 for Booleans. A complex number converts to a real dtype only when its imaginary part is zero, and otherwise gives a Domain error. Characters convert only to characters.
Sourcepub fn kept(view: View<'_>, dtype: DType) -> Result<Self, Error>
pub fn kept(view: View<'_>, dtype: DType) -> Result<Self, Error>
The items of view at dtype, where every item keeps its value. Items convert as Buffer::cast converts them, and a float that becomes a Boolean or an integer must be whole. A float rounds to a float of another width. A Domain error where an item doesn’t keep its value.
Source§impl Buffer
impl Buffer
Sourcepub fn floored(
view: View<'_>,
dtype: DType,
t: impl Tolerant,
) -> Result<Self, Error>
pub fn floored( view: View<'_>, dtype: DType, t: impl Tolerant, ) -> Result<Self, Error>
The items of view as integers of dtype, as BPL’s ₓ marks and Python’s astype convert them: a float takes its floor within t and saturates at the range, NaN giving 0 (crate::convert::floored); an integer wraps to the width; a Boolean gives 0 or 1. Other items and targets convert as Buffer::cast converts them.
pub fn cast_results( view: View<'_>, dtype: DType, checked: bool, ) -> Result<Self, Error>
Trait Implementations§
Source§impl IndexSource for Buffer
impl IndexSource for Buffer
Source§fn view(&self) -> View<'_>
fn view(&self) -> View<'_>
IndexValue).Auto Trait Implementations§
impl Forget for Buffer
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more