JaggedArray

Struct JaggedArray 

Source
pub struct JaggedArray<TVal, TBuffer: VecLike, const N: usize>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,
{ /* private fields */ }

Implementations§

Source§

impl<TVal, TBuffer: VecLike, const N: usize> JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num + NumAssignOps + PartialOrd + ConstOne + ConstZero, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt, usize: AsPrimitive<<TBuffer as VecLike>::TI>,

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: [usize; N]) -> Self

Source

pub fn reserve(&mut self, additional: [usize; N])

Source

pub fn buffer_reserve(&mut self, additional: usize)

Source

pub fn buffer_len(&self) -> usize

Source

pub fn buffer_capacity(&self) -> usize

Source

pub fn clear(&mut self)

Source

pub fn new_row<const DIM: usize>(&mut self)
where U<N>: Sub<U<DIM>>, Sub1<<U<N> as Sub<U<DIM>>>::Output>: Unsigned + NonZero, <U<N> as Sub<U<DIM>>>::Output: Sub<B1>, U<DIM>: ArrayLength, Const<N>: ToUInt, Const<DIM>: ToUInt,

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.new_row::<0>();
data.push_to_last_row(1);
assert!(data[[1,0]] == 1);
Source

pub fn push_to_last_row(&mut self, val: TVal)

Source

pub unsafe fn push_to_last_row_unchecked(&mut self, val: TVal)

§Safety

The caller must ensure that self.buffer_len() < self.buffer_capacity()

Source

pub fn pop_from_last_row(&mut self) -> Option<TVal>

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.push_to_last_row(1);
assert!(data.pop_from_last_row() == Some(1));
Source

pub fn extend_last_row(&mut self, values: impl Iterator<Item = TVal>)

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row([1,2,3].into_iter());
assert!(data[[0,0]] == 1);
assert!(data[[0,1]] == 2);
assert!(data[[0,2]] == 3);
Source

pub fn extend_last_row_from_slice(&mut self, values: &[TVal])
where TVal: Clone,

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row_from_slice(&[1,2,3]);
assert!(data[[0,0]] == 1);
assert!(data[[0,1]] == 2);
assert!(data[[0,2]] == 3);
Source

pub fn append_from_view<const M: usize>( &mut self, other: JaggedArrayView<'_, TVal, TBuffer::TI, M>, )
where U<N>: Sub<U<M>>, <U<N> as Sub<U<M>>>::Output: Unsigned, U<M>: Sub<B1> + ArrayLength, <U<M> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt, Const<M>: ToUInt, TVal: Clone,

§Example
use jaggedarray::jagged_array::JaggedArray;
use crate::jaggedarray::jagged_array::JaggedArrayViewTrait;
let mut data = JaggedArray::<usize, Vec<u16>, 3>::new();
data.new_row::<0>();
data.new_row::<1>();
data.extend_last_row_from_slice(&[1,2,3]);
let mut other = JaggedArray::<usize, Vec<u16>, 2>::new();
other.new_row::<0>();
other.extend_last_row_from_slice(&[4,5,6]);
data.append_from_view(other.view::<0,2>([]));
data.append_from_view(other.view::<1,1>([0]));
assert!(data[[0,0,0]] == 1);
assert!(data[[0,0,1]] == 2);
assert!(data[[0,0,2]] == 3);
assert!(data[[0,1,0]] == 4);
assert!(data[[0,1,1]] == 5);
assert!(data[[0,1,2]] == 6);
assert!(data[[0,1,3]] == 4);
assert!(data[[0,1,4]] == 5);
assert!(data[[0,1,5]] == 6);
Source

pub fn append<const M: usize>(&mut self, other: JaggedArray<TVal, TBuffer, M>)
where U<N>: Sub<U<M>>, <U<N> as Sub<U<M>>>::Output: Unsigned, U<M>: Sub<B1> + ArrayLength, <U<M> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt, Const<M>: ToUInt,

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row_from_slice(&[1,2,3]);
let mut other = JaggedArray::<usize, Vec<u16>, 2>::new();
other.new_row::<0>();
other.extend_last_row_from_slice(&[4,5,6]);
data.append(other);
assert!(data[[0,0]] == 1);
assert!(data[[0,1]] == 2);
assert!(data[[0,2]] == 3);
assert!(data[[1,0]] == 4);
assert!(data[[1,1]] == 5);
assert!(data[[1,2]] == 6);
Source

pub fn remove_last_row<const DIM: usize>(&mut self) -> bool
where U<N>: Sub<U<DIM>>, Sub1<<U<N> as Sub<U<DIM>>>::Output>: Unsigned + NonZero, <U<N> as Sub<U<DIM>>>::Output: Sub<B1>, U<DIM>: ArrayLength, Const<N>: ToUInt, Const<DIM>: ToUInt,

§Example
use jaggedarray::jagged_array::JaggedArray;
use crate::jaggedarray::jagged_array::JaggedArrayViewTrait;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row_from_slice(&[1,2,3]);
data.remove_last_row::<0>();
assert!(data.is_empty());
Source

pub fn remove_rows(&mut self, range: Range<usize>)
where U<N>: NonZero,

§Example
use jaggedarray::jagged_array::JaggedArray;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row_from_slice(&[1, 2, 3]);
data.new_row::<0>();
data.extend_last_row_from_slice(&[4, 5, 6]);
data.new_row::<0>();
data.extend_last_row_from_slice(&[7, 8, 9]);
data.remove_rows(1..2);
assert!(data[[0, 0]] == 1);
assert!(data[[0, 1]] == 2);
assert!(data[[0, 2]] == 3);
assert!(data[[1, 0]] == 7);
assert!(data[[1, 1]] == 8);
assert!(data[[1, 2]] == 9);
Source

pub fn truncate<const DIM: usize>(&mut self, row_length: usize) -> bool

§Example
use jaggedarray::jagged_array::JaggedArray;
use crate::jaggedarray::jagged_array::JaggedArrayViewTrait;
let mut data = JaggedArray::<usize, Vec<u16>, 2>::new();
data.new_row::<0>();
data.extend_last_row_from_slice(&[1,2,3]);
data.truncate::<0>(1);
assert!(data[[0,0]] == 1);

Trait Implementations§

Source§

impl<TVal: Clone, TBuffer: Clone + VecLike, const N: usize> Clone for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn clone(&self) -> JaggedArray<TVal, TBuffer, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<TVal: Debug, TBuffer: Debug + VecLike, const N: usize> Debug for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<TVal, TBuffer: VecLike, const N: usize> Default for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num + ConstOne + ConstZero, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<TVal: Hash, TBuffer: Hash + VecLike, const N: usize> Hash for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<TVal, TBuffer, const N: usize> Index<[usize; N]> for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, TBuffer: VecLike, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

type Output = TVal

The returned type after indexing.
Source§

fn index(&self, index: [usize; N]) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<TVal, TBuffer, const N: usize> IndexMut<[usize; N]> for JaggedArray<TVal, TBuffer, N>
where TBuffer: VecLike, <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1> + ArrayLength, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn index_mut(&mut self, index: [usize; N]) -> &mut TVal

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<TVal, TBuffer> JaggedArray1DViewTrait<TVal, <TBuffer as VecLike>::TI> for JaggedArray<TVal, TBuffer, 1>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, TBuffer: VecLike,

Source§

fn as_slice(&self) -> &[TVal]

Source§

impl<TVal, TBuffer, const N: usize> JaggedArrayMutViewTrait<TVal, <TBuffer as VecLike>::TI, N> for JaggedArray<TVal, TBuffer, N>
where TBuffer: VecLike, <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num + ConstOne + ConstZero, U<N>: Sub<B1> + ArrayLength, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn view_mut<const M: usize, const R: usize>( &mut self, index: [usize; M], ) -> JaggedArrayMutView<'_, TVal, <TBuffer as VecLike>::TI, R>
where U<N>: Sub<U2> + Sub<B1> + Sub<U<M>>, <U<N> as Sub<U2>>::Output: ArrayLength, <U<N> as Sub<B1>>::Output: Sub<B1>, <<U<N> as Sub<B1>>::Output as Sub<B1>>::Output: ArrayLength, <U<N> as Sub<U<M>>>::Output: IsEqual<U<R>>, U<R>: Sub<B1>, <U<R> as Sub<B1>>::Output: ArrayLength, <<U<N> as Sub<U<M>>>::Output as IsEqual<U<R>>>::Output: NonZero, Const<N>: ToUInt, Const<M>: ToUInt, Const<R>: ToUInt,

Rust const generics does not support arithmetic, so we have to specify the view’s dimension(R) as well

Source§

impl<TVal, TBuffer, const N: usize> JaggedArrayViewTrait<TVal, <TBuffer as VecLike>::TI, N> for JaggedArray<TVal, TBuffer, N>
where TBuffer: VecLike, <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num + ConstOne + ConstZero, U<N>: Sub<B1> + ArrayLength, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn view<const M: usize, const R: usize>( &self, index: [usize; M], ) -> JaggedArrayView<'_, TVal, <TBuffer as VecLike>::TI, R>
where U<N>: Sub<U2> + Sub<B1> + Sub<U<M>>, <U<N> as Sub<U2>>::Output: ArrayLength, <U<N> as Sub<B1>>::Output: Sub<B1>, <<U<N> as Sub<B1>>::Output as Sub<B1>>::Output: ArrayLength, <U<N> as Sub<U<M>>>::Output: IsEqual<U<R>>, U<R>: Sub<B1>, <U<R> as Sub<B1>>::Output: ArrayLength, <<U<N> as Sub<U<M>>>::Output as IsEqual<U<R>>>::Output: NonZero, Const<N>: ToUInt, Const<M>: ToUInt, Const<R>: ToUInt,

Rust const generics does not support arithmetic, so we have to specify the view’s dimension(R) as well

Source§

unsafe fn view_unchecked<const M: usize, const R: usize>( &self, index: [usize; M], ) -> JaggedArrayView<'_, TVal, <TBuffer as VecLike>::TI, R>
where U<N>: Sub<U2> + Sub<B1> + Sub<U<M>>, <U<N> as Sub<U2>>::Output: ArrayLength, <U<N> as Sub<B1>>::Output: Sub<B1>, <<U<N> as Sub<B1>>::Output as Sub<B1>>::Output: ArrayLength, <U<N> as Sub<U<M>>>::Output: IsEqual<U<R>>, U<R>: Sub<B1>, <U<R> as Sub<B1>>::Output: ArrayLength, <<U<N> as Sub<U<M>>>::Output as IsEqual<U<R>>>::Output: NonZero, Const<N>: ToUInt, Const<M>: ToUInt, Const<R>: ToUInt,

Rust const generics does not support arithmetic, so we have to specify the view’s dimension(R) as well

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

unsafe fn get_unchecked(&self, index: [usize; N]) -> &TVal

Safety Read more
Source§

fn get(&self, index: [usize; N]) -> Option<&TVal>

Source§

fn to_owned(self) -> JaggedArrayOwnedView<TVal, <TBuffer as VecLike>::TI, N>
where TVal: Clone,

Source§

impl<TVal: PartialEq, TBuffer: PartialEq + VecLike, const N: usize> PartialEq for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

fn eq(&self, other: &JaggedArray<TVal, TBuffer, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<TVal: Eq, TBuffer: Eq + VecLike, const N: usize> Eq for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Source§

impl<TVal, TBuffer: VecLike, const N: usize> StructuralPartialEq for JaggedArray<TVal, TBuffer, N>
where <TBuffer as VecLike>::TI: AsPrimitive<usize> + Num, U<N>: Sub<B1>, <U<N> as Sub<B1>>::Output: ArrayLength, Const<N>: ToUInt,

Auto Trait Implementations§

§

impl<TVal, TBuffer, const N: usize> !Freeze for JaggedArray<TVal, TBuffer, N>

§

impl<TVal, TBuffer, const N: usize> !RefUnwindSafe for JaggedArray<TVal, TBuffer, N>

§

impl<TVal, TBuffer, const N: usize> Send for JaggedArray<TVal, TBuffer, N>
where <<Const<N> as ToUInt>::Output as Sub<B1>>::Output: Sized, <TBuffer as VecLike>::TI: Sized, TBuffer: Send, TVal: Send,

§

impl<TVal, TBuffer, const N: usize> Sync for JaggedArray<TVal, TBuffer, N>
where <<Const<N> as ToUInt>::Output as Sub<B1>>::Output: Sized, <TBuffer as VecLike>::TI: Sized, TBuffer: Sync, TVal: Sync,

§

impl<TVal, TBuffer, const N: usize> !Unpin for JaggedArray<TVal, TBuffer, N>

§

impl<TVal, TBuffer, const N: usize> !UnwindSafe for JaggedArray<TVal, TBuffer, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.