Rudiments
|
Public Member Functions | |
staticarray () | |
staticarray (const staticarray< valuetype, length > &v) | |
staticarray< valuetype, length > & | operator= (const staticarray< valuetype, length > &v) |
~staticarray () | |
valuetype & | operator[] (uint64_t index) |
uint64_t | getLength () const |
void | clear () |
The staticarray class allows you to store a pre-defined number of values and access them with array-like syntax.
"valuetype" can be any scalar type, including a pointer, but cannot be an array.
Ie. these are legal: staticarray< int, 10 > d; staticarray< myclass, 10 > d; staticarray< myclass *, 10 > d;
These are not legal and whether they work or even compile would be platform-dependent: staticarray< int[100], 10 > d; staticarray< myclass[100], 10 > d; staticarray< myclass *[100], 10 > d;
However, it is possible to create an array of arrays by nesting staticarrays or dynamicarrays, like:
staticarray< staticarray< int >, 10 > d; staticarray< staticarray< myclass >, 10 > d; staticarray< staticarray< myclass * >, 10 > d; staticarray< dynamicarray< int >, 10 > d; staticarray< dynamicarray< myclass >, 10 > d; staticarray< dynamicarray< myclass * >, 10 > d;
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::staticarray | ( | ) |
Creates an empty instance of the staticarray class with "length" elements. "length" is given in the template definition.
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::staticarray | ( | const staticarray< valuetype, length > & | v | ) |
Creates an instance of the staticarray class that is a copy of "v".
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length >::~staticarray | ( | ) |
Deletes this instance of the staticarray class and all of its values.
RUDIMENTS_TEMPLATE_INLINE void staticarray< valuetype, length >::clear | ( | ) |
Clears the array, deleting all of its values.
RUDIMENTS_TEMPLATE_INLINE uint64_t staticarray< valuetype, length >::getLength | ( | ) | const |
Returns the length of the array.
RUDIMENTS_TEMPLATE_INLINE staticarray< valuetype, length > & staticarray< valuetype, length >::operator= | ( | const staticarray< valuetype, length > & | v | ) |
Makes this instance of the staticarray class identical to "v".
RUDIMENTS_TEMPLATE_INLINE valuetype & staticarray< valuetype, length >::operator[] | ( | uint64_t | index | ) |
Provides access to the "index"th element of the staticarray.