#include <ShortArray.hpp>
Public Member Functions | |
ShortArray () | |
ShortArray (const ShortArray &)=delete | |
ShortArray (size_t n) | |
~ShortArray () | |
void | clear () |
ShortArray & | operator= (const ShortArray &)=delete |
double & | operator[] (size_t i) |
double | operator[] (size_t i) const |
void | resize (size_t n) |
size_t | size () const |
Static Public Attributes | |
static const int | N |
Private Attributes | |
double | _a [N] |
size_t | _c |
size_t | _n |
double * | _p |
A ShortArray instance holds a an array of double values that is usually shorter than the compile-time constant ShortArray::N but can be larger if needed. As long as the array is not longer than N, no heap allocations occur. If the array does become longer than N, the appropriate space is allocated on the heap. The number of items held by the array can be adjusted, but only at the cost of erasing all previously stored values: the resize operation sets all values to zero, just as if the array was freshly constructed. ShortArray instances cannot be copied or moved.
In the current implementation, the value of N is 8.
|
inline |
The default constructor creates an empty array.
|
inlineexplicit |
This constructor creates an empty array with the specified number of values, all initialized to zero.
|
delete |
The copy constructor is deleted.
|
inline |
The destructor releases the memory buffer if it was allocated on the heap.
|
inline |
This function clears all values held by the array to zero.
|
delete |
The assignment operator is deleted.
|
inline |
This function returns a writable reference to the specified array element.
|
inline |
This function returns a read-only reference to the specified array element.
|
inline |
This function resizes the array so that it holds the specified number of values. The values are initialized to zero; the previous contents is lost. All iterators are invalidated.
|
inline |
This function returns the number of values held by the array.