PackageDescription: SYSEXT-MultipleDimensionArray

SYSEXT - Multiple Dimension Array

Last published: March 26, 2018 by 'nice'

Defines 3 Classes
Extends 4 Classes

Add a MultipleDimensionArray : this is an arrayed collection whose elements are accessed using multiple indices.
This exists in almost every language (C FORTRAN Pascal Ada etc...).

The Smalltalkish solution consisting of making Array of Array of... looks like the C solution of making arrays of pointers...
That is a nice possibility.
But, sometimes for efficiency in handling and storing, or need of symetry, or for handling a set of indices as a whole,
or simply for exchanging informations with other languages,
it is better to have a mean to point on a flat collection of elements through a collection of indices...
This is the aim of this class.

There are messages for converting to and from underlying flat Arrays, or recursive Arrays of arrays of...
(1 to: 12) asArrayWithMultipleDimensions: #(2 3 2).
#(#(1 2 3) #(4 5 6)) asMultipleDimensionArray asArray
Notice the ordering of elements : it is like FORTRAN by default : the first index changes first (a.k.a. column-major)...
However, the package also provides a row-major variant like in C language.

The protocol for accessing a single element with multiple indices accessing is :

There is also a Matlabish_Fortran_95ish way of accessing sub-collections :

Classical Smalltalk messages are used to access the underlying flat collection :

So as the Matlabish_Fortran_95ish way of accessing sub-collections :