Scopira
20080306
|
Note! See Numeric arrays if you want arrays (and multidimentional arrays) for numeric computing.
Scopira includes several basic, generic arrays. These classes have several distinct characterists when compared to std::vector.
scopira::tool::basic_array is a simple template class that implements a straight dynamic array. It can be of any type. This template should be used instead of dynamic C arrays.
For example:
Could be replaced with:
Note that basic_array's constructor, destructor and resize methods all take care of any proper memory clean up needs.
Other features of scopira::tool::basic_array include:
scopira::tool::fixed_array is a template class that implements constant size C arrays. For example, code like this:
Could be replaced by:
Fixed arrays provide the following benefits:
scopira::tool::basic_matrix is a template class that that implements a two dimensional matrix or grid of objects. The matrix has a width and height. The matrix is thought to have graphics-like coordinates. That is, the first coordinate (x) go from 0 to width, left to right. The second coordinate (y) goes from 0 to height, top down.
Internally, this class utilizes scopira::tool::basic_array. The following additional methods are provided:
scopira::tool::hybrid_array is a scopira::tool::basic_array that has some preallocaed storage via an internal scopira::tool::fixed_array. This is particularly handy when most of the uses of the array will only require a few elements, but still need the flexibily of heap allocated storage for the few cases that go over this threshold.