#[repr(C)]pub struct Array<T> { /* private fields */ }
Expand description
Uiua’s array type
Implementations§
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn fill_to_shape(&mut self, shape: &[usize], fill_value: T)
pub fn fill_to_shape(&mut self, shape: &[usize], fill_value: T)
Fill the array with the given value so it matches the given shape
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn join(self, other: Self, allow_ext: bool, env: &Uiua) -> UiuaResult<Self>
pub fn join(self, other: Self, allow_ext: bool, env: &Uiua) -> UiuaResult<Self>
join
the array with another
Sourcepub fn join_infallible(self, other: Self, allow_ext: bool) -> Self
pub fn join_infallible(self, other: Self, allow_ext: bool) -> Self
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn couple(
self,
other: Self,
allow_ext: bool,
env: &Uiua,
) -> UiuaResult<Self>
pub fn couple( self, other: Self, allow_ext: bool, env: &Uiua, ) -> UiuaResult<Self>
couple
the array with another
Sourcepub fn couple_infallible(self, other: Self, allow_ext: bool) -> Self
pub fn couple_infallible(self, other: Self, allow_ext: bool) -> Self
Sourcepub fn uncouple(self, env: &Uiua) -> UiuaResult<(Self, Self)>
pub fn uncouple(self, env: &Uiua) -> UiuaResult<(Self, Self)>
Uncouple the array into two arrays
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn from_row_arrays<V>(values: V, env: &Uiua) -> UiuaResult<Self>
pub fn from_row_arrays<V>(values: V, env: &Uiua) -> UiuaResult<Self>
Create an array from row arrays
Sourcepub fn from_row_arrays_infallible<V>(values: V) -> Self
pub fn from_row_arrays_infallible<V>(values: V) -> Self
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: Clone> Array<T>
impl<T: Clone> Array<T>
Sourcepub fn reshape_scalar(
&mut self,
count: Result<isize, bool>,
env: &Uiua,
) -> UiuaResult
pub fn reshape_scalar( &mut self, count: Result<isize, bool>, env: &Uiua, ) -> UiuaResult
reshape
this array by replicating it as the rows of a new array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: Clone + Send + Sync> Array<T>
impl<T: Clone + Send + Sync> Array<T>
Sourcepub fn keep_scalar_integer(self, count: usize, env: &Uiua) -> UiuaResult<Self>
pub fn keep_scalar_integer(self, count: usize, env: &Uiua) -> UiuaResult<Self>
keep
this array by replicating it as the rows of a new array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn keep_scalar_real(self, count: f64, env: &Uiua) -> UiuaResult<Self>
pub fn keep_scalar_real(self, count: f64, env: &Uiua) -> UiuaResult<Self>
keep
this array with a real-valued scalar
Sourcepub fn keep_list(self, counts: &[f64], env: &Uiua) -> UiuaResult<Self>
pub fn keep_list(self, counts: &[f64], env: &Uiua) -> UiuaResult<Self>
keep
this array with some counts
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn windows(&self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>
pub fn windows(&self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>
Get the windows
of this array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn chunks(self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>
pub fn chunks(self, isize_spec: &[isize], env: &Uiua) -> UiuaResult<Self>
Get chunks
of this array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn unfix(&mut self, env: &Uiua) -> UiuaResult
pub fn unfix(&mut self, env: &Uiua) -> UiuaResult
Remove a 1-length dimension from the front of the array’s shape
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn first(self, env: &Uiua) -> UiuaResult<Self>
pub fn first(self, env: &Uiua) -> UiuaResult<Self>
Get the first row of the array
Sourcepub fn last(self, env: &Uiua) -> UiuaResult<Self>
pub fn last(self, env: &Uiua) -> UiuaResult<Self>
Get the last row of the array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn deduplicate(&mut self, env: &Uiua) -> UiuaResult
pub fn deduplicate(&mut self, env: &Uiua) -> UiuaResult
deduplicate
the rows of the array
Sourcepub fn count_unique(&self) -> usize
pub fn count_unique(&self) -> usize
Count the number of unique rows in the array
Source§impl<T: RealArrayValue> Array<T>
impl<T: RealArrayValue> Array<T>
Sourcepub fn bits(&self, env: &Uiua) -> UiuaResult<Value>
pub fn bits(&self, env: &Uiua) -> UiuaResult<Value>
Encode the bits
of the array
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn un_bits(&self, env: &Uiua) -> UiuaResult<Value>
pub fn un_bits(&self, env: &Uiua) -> UiuaResult<Value>
Decode the bits
of the array
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn new(shape: impl Into<Shape>, data: impl Into<CowSlice<T>>) -> Self
pub fn new(shape: impl Into<Shape>, data: impl Into<CowSlice<T>>) -> Self
Create an array from a shape and data
§Panics
Panics in debug mode if the shape does not match the data length
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Get the number of elements in the array
Sourcepub fn elements(&self) -> impl ExactDoubleIterator<Item = &T>
pub fn elements(&self) -> impl ExactDoubleIterator<Item = &T>
Iterate over the elements of the array
Sourcepub fn get_meta_mut(&mut self) -> Option<&mut ArrayMeta>
pub fn get_meta_mut(&mut self) -> Option<&mut ArrayMeta>
Get a mutable reference to the metadata of the array if it exists
Sourcepub fn meta_mut(&mut self) -> &mut ArrayMeta
pub fn meta_mut(&mut self) -> &mut ArrayMeta
Get a mutable reference to the metadata of the array
Sourcepub fn take_label(&mut self) -> Option<EcoString>
pub fn take_label(&mut self) -> Option<EcoString>
Take the label from the metadata
Sourcepub fn take_map_keys(&mut self) -> Option<MapKeys>
pub fn take_map_keys(&mut self) -> Option<MapKeys>
Take the map keys from the metadata
Sourcepub fn take_per_meta(&mut self) -> PersistentMeta
pub fn take_per_meta(&mut self) -> PersistentMeta
The the persistent metadata of the array
Sourcepub fn set_per_meta(&mut self, per_meta: PersistentMeta)
pub fn set_per_meta(&mut self, per_meta: PersistentMeta)
Set the map keys in the metadata
Sourcepub fn map_keys_mut(&mut self) -> Option<&mut MapKeys>
pub fn map_keys_mut(&mut self) -> Option<&mut MapKeys>
Get a mutable reference to the map keys
Sourcepub fn reset_meta_flags(&mut self)
pub fn reset_meta_flags(&mut self)
Reset all metadata flags
Sourcepub fn row_slices(
&self,
) -> impl ExactSizeIterator<Item = &[T]> + DoubleEndedIterator + Clone + Send + Sync
pub fn row_slices( &self, ) -> impl ExactSizeIterator<Item = &[T]> + DoubleEndedIterator + Clone + Send + Sync
Get an iterator over the row slices of the array
Sourcepub fn combine_meta(&mut self, other: &ArrayMeta)
pub fn combine_meta(&mut self, other: &ArrayMeta)
Combine the metadata of two arrays
This combines:
- flags
- map keys
- handle kind
Notably, this does not combine the label, as label combination should be more nuanced.
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn into_scalar(self) -> Result<T, Self>
pub fn into_scalar(self) -> Result<T, Self>
Attempt to convert the array into a scalar
Sourcepub fn as_scalar_mut(&mut self) -> Option<&mut T>
pub fn as_scalar_mut(&mut self) -> Option<&mut T>
Attempt to get a mutable reference to the scalar value
Sourcepub fn rows(
&self,
) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_
pub fn rows( &self, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_
Get an iterator over the row arrays of the array
Sourcepub fn row_shaped_slices(
&self,
row_shape: Shape,
) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_
pub fn row_shaped_slices( &self, row_shape: Shape, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator + '_
Get an iterator over the row arrays of the array that have the given shape
Sourcepub fn into_row_shaped_slices(
self,
row_shape: Shape,
) -> impl DoubleEndedIterator<Item = Self>
pub fn into_row_shaped_slices( self, row_shape: Shape, ) -> impl DoubleEndedIterator<Item = Self>
Get an iterator over the row arrays of the array that have the given shape
Sourcepub fn slice_rows(&self, start: usize, end: usize) -> Self
pub fn slice_rows(&self, start: usize, end: usize) -> Self
Create an array that is a slice of this array’s rows
Generally doesn’t allocate
start
must be <=end
start
must be <self.row_count()
end
must be <=self.row_count()
Sourcepub fn into_rows(
self,
) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator
pub fn into_rows( self, ) -> impl ExactSizeIterator<Item = Self> + DoubleEndedIterator
Consume the array and get an iterator over its rows
Sourcepub fn show(&self) -> String
pub fn show(&self) -> String
Get a pretty-printed string representing the array
This is what is printed by the &s
function
Sourcepub fn row_slice_mut(&mut self, row: usize) -> &mut [T]
pub fn row_slice_mut(&mut self, row: usize) -> &mut [T]
Get a mutable slice of a row
Source§impl<T: Clone> Array<T>
impl<T: Clone> Array<T>
Sourcepub fn convert_with<U: Clone>(self, f: impl FnMut(T) -> U) -> Array<U>
pub fn convert_with<U: Clone>(self, f: impl FnMut(T) -> U) -> Array<U>
Convert the elements of the array with a function
Sourcepub fn try_convert_with<U: Clone, E>(
self,
f: impl FnMut(T) -> Result<U, E>,
) -> Result<Array<U>, E>
pub fn try_convert_with<U: Clone, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<Array<U>, E>
Convert the elements of the array with a fallible function
Sourcepub fn convert_ref<U>(&self) -> Array<U>
pub fn convert_ref<U>(&self) -> Array<U>
Convert the elements of the array without consuming it
Sourcepub fn convert_ref_with<U: Clone>(&self, f: impl FnMut(T) -> U) -> Array<U>
pub fn convert_ref_with<U: Clone>(&self, f: impl FnMut(T) -> U) -> Array<U>
Convert the elements of the array with a function without consuming it
Source§impl Array<Boxed>
impl Array<Boxed>
Sourcepub fn into_unboxed(self) -> Result<Value, Self>
pub fn into_unboxed(self) -> Result<Value, Self>
Attempt to unbox a scalar box array
Sourcepub fn as_unboxed(&self) -> Option<&Value>
pub fn as_unboxed(&self) -> Option<&Value>
Attempt to unbox a scalar box array
Sourcepub fn as_unboxed_mut(&mut self) -> Option<&mut Value>
pub fn as_unboxed_mut(&mut self) -> Option<&mut Value>
Attempt to unbox a scalar box array
Source§impl<T: ArrayValue> Array<T>
impl<T: ArrayValue> Array<T>
Sourcepub fn shape_string(&self) -> String
pub fn shape_string(&self) -> String
Get a string representation of the shape of the array
Trait Implementations§
Source§impl<T: ArrayValue> Default for Array<T>
impl<T: ArrayValue> Default for Array<T>
Source§impl<'de, T> Deserialize<'de> for Array<T>where
T: ArrayValueSer + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Array<T>where
T: ArrayValueSer + Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: ArrayValue> From<T> for Array<T>
impl<T: ArrayValue> From<T> for Array<T>
Source§impl<T: ArrayValue> FromIterator<T> for Array<T>
impl<T: ArrayValue> FromIterator<T> for Array<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<T: ArrayValue> Hash for Array<T>
impl<T: ArrayValue> Hash for Array<T>
Source§impl<T: ArrayValue> Ord for Array<T>
impl<T: ArrayValue> Ord for Array<T>
Source§impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialEq<Array<U>> for Array<T>
impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialEq<Array<U>> for Array<T>
Source§impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialOrd<Array<U>> for Array<T>
impl<T: ArrayValue + ArrayCmp<U>, U: ArrayValue> PartialOrd<Array<U>> for Array<T>
impl<T: ArrayValue> Eq for Array<T>
Auto Trait Implementations§
impl<T> Freeze for Array<T>
impl<T> RefUnwindSafe for Array<T>where
T: RefUnwindSafe,
impl<T> Send for Array<T>
impl<T> Sync for Array<T>
impl<T> Unpin for Array<T>where
T: Unpin,
impl<T> UnwindSafe for Array<T>where
T: RefUnwindSafe + UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.