Type Alias hazardflow_designs::std::value::U
source · pub type U<const N: usize> = Array<bool, N>;
Expand description
An unsigned integer with bitwidth N
.
The lower bits of the integer are represented by the lower index of the array, and vice versa. In other words, the
least significant bit of the integer is the 0th element of the array, and the most significant bit is the
(N
- 1)-th element.
Aliased Type§
struct U<const N: usize> { /* private fields */ }
Implementations§
source§impl<const N: usize> U<N>
impl<const N: usize> U<N>
sourcepub fn unsigned_max() -> U<N>
pub fn unsigned_max() -> U<N>
Returns the maximum value of an N
bit unsigned value. (i.e., 2^N
- 1)
source§impl<V: Copy + Default, const N: usize> Array<V, N>
impl<V: Copy + Default, const N: usize> Array<V, N>
sourcepub fn fold_assoc<F: FnOnce(V, V) -> V>(self, f: F) -> V
pub fn fold_assoc<F: FnOnce(V, V) -> V>(self, f: F) -> V
Folds the array into a single value.
The fold order is not guaranteed, so the operation f
must be associative.
source§impl<V: Copy, const N: usize> Array<V, N>
impl<V: Copy, const N: usize> Array<V, N>
sourcepub fn set<Idx: Into<U<{ _ }>>>(self, _idx: Idx, _elt: V) -> Array<V, N>
pub fn set<Idx: Into<U<{ _ }>>>(self, _idx: Idx, _elt: V) -> Array<V, N>
Returns a new array with the idx
-th element set to elt
.
sourcepub fn set_cond(self, cond: bool, idx: U<{ _ }>, elt: V) -> Array<V, N>
pub fn set_cond(self, cond: bool, idx: U<{ _ }>, elt: V) -> Array<V, N>
Returns a new array with the idx
-th element set to elt
if cond
is true.
sourcepub fn clip_const<const M: usize>(self, _index: usize) -> Array<V, M>
pub fn clip_const<const M: usize>(self, _index: usize) -> Array<V, M>
Returns a new clipped array of size M
starting from index
.
sourcepub fn zip<W: Copy>(self, _other: Array<W, N>) -> Array<(V, W), N>
pub fn zip<W: Copy>(self, _other: Array<W, N>) -> Array<(V, W), N>
Returns a new array that has tuples from the two given arrays as elements.
sourcepub fn enumerate(self) -> Array<(U<{ _ }>, V), N>
pub fn enumerate(self) -> Array<(U<{ _ }>, V), N>
Returns a new array whose elements are enumerated with their indices.
sourcepub fn map<W: Copy, F: FnOnce(V) -> W>(self, _f: F) -> Array<W, N>
pub fn map<W: Copy, F: FnOnce(V) -> W>(self, _f: F) -> Array<W, N>
Transforms elements of self
using f
.
sourcepub fn fold<B: Copy, F: FnOnce(B, V) -> B>(self, _init: B, _f: F) -> B
pub fn fold<B: Copy, F: FnOnce(B, V) -> B>(self, _init: B, _f: F) -> B
Folds the array into a single value.
The fold order is from left to right. (i.e. foldl
)
sourcepub fn all<F: Fn(V) -> bool>(self, f: F) -> bool
pub fn all<F: Fn(V) -> bool>(self, f: F) -> bool
Tests if every element matches a predicate. TODO: Use tree fold?
sourcepub fn chunk<const M: usize>(self) -> Array<Array<V, M>, { _ }>
pub fn chunk<const M: usize>(self) -> Array<Array<V, M>, { _ }>
Chunks the array into an array of arrays.
sourcepub fn append<const M: usize>(self, _other: Array<V, M>) -> Array<V, { _ }>
pub fn append<const M: usize>(self, _other: Array<V, M>) -> Array<V, { _ }>
Returns a new array with the two given arrays appended.
sourcepub fn set_range<const M: usize>(
self,
_index: usize,
_other: Array<V, M>
) -> Array<V, N>
pub fn set_range<const M: usize>( self, _index: usize, _other: Array<V, M> ) -> Array<V, N>
Returns a new array with the M
elements starting from index
set to the elements of other
.