This article presents a system for C++ arrays. This system is
superior to the arrays that are built into the C and C++ languages in
that arrays can be resized dynamically at runtime and also they are
safer to use through the use of assertions to guard against array out
of bounds errors.
1. Using Arrays
See the file t-array.cc for examples of using arrays.
Multi-dimensional arrays are also supported. See the source code file
t-array.cc for an example of
their use. Like C arrays, the indexing is opposite from normal
use. Here is how to index into a two-dimensional array:
a->get_element_at(y)->get_element_at(x)
Note that deletions from multi-dimensional arrays is
non-trivial. See the source code file for an example of deleting
from multi-dimensional arrays. When using multi-dimensional arrays,
typedefs are useful: The following line of code defines an alias for
a two-dimensional array of ints.
typedef Array<Array<int> > Array_Array_Int
In the above example, care must be taken to put spaces between the
closing >'s.