|
|
T & | operator[] (int n) |
| reference n 'th element.
|
|
const T & | operator[] (int n) const |
| reference n 'th element.
|
|
T * | get_ptr () |
|
const T * | get_const_ptr () const |
| get a const C pointer to the data.
|
|
void | append (const T &t) |
| append 1 elements with value t .
|
|
void | append (int n) |
| append n uninitialized elements.
|
|
void | append (int n, const T &t) |
| append n elements with value t .
|
|
void | append (int n, const T t[]) |
| append n elements from t .
|
|
void | append (const Array< T > &t) |
| append all elements from p_array .
|
|
void | insert (int i, int n) |
| insert n uninitialized elements before i 'th element.
|
|
void | insert (int i, int n, const T &t) |
| insert n elements with value t before i 'the element.
|
|
void | insert (int i, int n, const T t[]) |
| insert n elements from p_array before i 'th element.
|
|
void | insert (int i, const Array< T > &t) |
| insert all elements from p_array before i 'th element.
|
|
void | remove (int n=0, int m=1) |
| remove m elements starting at n .
|
|
void | clear () |
| remove all elements.
|
|
int | size () const |
| return the number of elements.
|
|
void | reSize (int newsize) |
| reset the number of elements.
|
|
|
Array< T > & | operator= (const Array< T > &rhs) |
| assignment operator.
|
|
Array & | operator= (const Array &&rhs) |
|
| Array (int n=0) |
| default constructor.
|
|
| Array (const Array &old) |
| copy constructor
|
|
| ~Array () |
| destructor
|
|
void | push_back (const T &val) |
|
void | push_back (T &&val) |
|
bool | isConsistent () const |
| Consistency check.
|
|
template<class T>
class soplex::Array< T >
Safe arrays of arbitrary types.
Class Array provides safe arrays of arbitrary type. Array elements are accessed just like ordinary C++ array elements by means of the index operator[](). Safety is provided by
- automatic memory management in constructor and destructor preventing memory leaks
- checking of array bound when accessing elements with the indexing operator[]() (only when compiled without
-DNDEBUG
).
Moreover, Arrays may easily be extended by inserting or appending elements to the Array or shrunken by removing elements. Method reSize(int n) resets the Array's length to n
, thereby appending elements or truncating the Array to the required size.
An Array is implemented in a C++-compliant way with respect to how memory is managed: Only operators new and delete are used for allocating memory. This involves some overhead for all methods effecting the length of an Array, i.e., all methods insert(), append(), remove() and reSize(). This involves allocating a new C++ array of the new size and copying all elements with the template parameters operator=().
For this reason, it is not convenient to use class Array if its elements are Data Objects. In this case use class DataArray instead.
- See also
- DataArray, Data Objects
Definition at line 72 of file array.h.