Dynamic Array
|
 |
This data structure is used just
like an ordinary array. Apart from its ability to grow and shrink, it overloads
all numeric operations so in most cases loops will not be necessary. For
instance, for two arrays A and B, the operation A+=B adds every cell of B to its
corresponding cell of A.
The overloaded operators make
sense for numeric types. However, you may overload operators for the type that
instantiates the template.
Declaration
#include<ospace/advanced/Array.h>
template
<
class Instantiator
>
class os_Array
Interface
Constructor
os_Array(int i=32, int j=32)
This the default
constructor. First argument is for initial size of array. Second argument is
used for expanding or shrinking array. You can over-ride the defaults.
Destructor
~os_Array()
Destroys the array and
its contents.
=
os_Array<T>& operator=(const
os_Array<T>&)
All operators are
overloaded, and documented in the source.
Size
int Size(void)
Returns the current size
of the array.
expand
int expand(const int
index)
Resize by enlarging the
array to include at least as many cells as index.
shrink
int shrink(const int
index)
Resize by reducing the
array to include at least as many cells as index.
operator[]
T&
operator[](int index)
This makes dynamic array
work just like ordinary array.
Copyright©2005-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.