dyn_array

Crates.iodyn_array
lib.rsdyn_array
version0.1.7
sourcesrc
created_at2022-09-12 20:13:50.194553
updated_at2022-12-04 20:22:54.101358
descriptionA simple, easy to use N-dimensional dynamic array
homepage
repository
max_upload_size
id663989
size10,372
(Xx-EvilPanda-xX)

documentation

README

dyn_array - A simple, easy to use N-dimensional dynamic array

A DynArray can be constructed in two ways:

  1. DynArray::new - specify dimensions and default value
  2. DynArray::new_from_data - specify dimensions and a vector that contains pre initialized data

All indexing is done with std::ops::Index by passing in an array to specify which element is wanted. Ex:

let elem = arr[[10, 10, 10]];

DynArray can also be iterated over in a couple of ways. First, the data and data_mut provide a contiguous slice of the elements without any regard to the dimensions of the DynArray. The provided slice can then be iterated. There is also an Iterator implemention for DynArray that gives you immutable access to each element while also providing the associated index.

Ex:

// 20 by 20 integer array let mut arr = DynArray::new([20, 20], 3);

for i in arr.data_mut() { //mutable access to elements, but no indication of current index }

for (index, elem) in &arr { //immutable access to elements and the current index let [x, y] = index; }

Commit count: 0

cargo fmt