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. More...
#include <array.h>
Public Member Functions | |
Access / modification | |
T & | operator[] (int n) |
reference n 'th element. More... | |
const T & | operator[] (int n) const |
reference n 'th element. More... | |
T * | get_ptr () |
const T * | get_const_ptr () const |
get a const C pointer to the data. More... | |
void | append (const T &t) |
append 1 elements with value t . More... | |
void | append (int n) |
append n uninitialized elements. More... | |
void | append (int n, const T &t) |
append n elements with value t . More... | |
void | append (int n, const T t[]) |
append n elements from t . More... | |
void | append (const Array< T > &t) |
append all elements from p_array . More... | |
void | insert (int i, int n) |
insert n uninitialized elements before i 'th element. More... | |
void | insert (int i, int n, const T &t) |
insert n elements with value t before i 'the element. More... | |
void | insert (int i, int n, const T t[]) |
insert n elements from p_array before i 'th element. More... | |
void | insert (int i, const Array< T > &t) |
insert all elements from p_array before i 'th element. More... | |
void | remove (int n=0, int m=1) |
remove m elements starting at n . More... | |
void | clear () |
remove all elements. More... | |
int | size () const |
return the number of elements. More... | |
void | reSize (int newsize) |
reset the number of elements. More... | |
Construction / destruction | |
Array< T > & | operator= (const Array< T > &rhs) |
assignment operator. More... | |
Array & | operator= (const Array &&rhs) |
Array (int n=0) | |
default constructor. More... | |
Array (const Array &old) | |
copy constructor More... | |
~Array () | |
destructor More... | |
void | push_back (const T &val) |
void | push_back (T &&val) |
bool | isConsistent () const |
Consistency check. More... | |
Protected Attributes | |
Data | |
std::vector< T > | data |
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.
-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.
|
explicit |
void append | ( | const T & | t | ) |
append 1 elements with value t
.
Definition at line 107 of file array.h.
Referenced by Array< soplex::UnitVectorBase * >::append().
void append | ( | int | n, |
const T & | t | ||
) |
void append | ( | int | n, |
const T | t[] | ||
) |
void append | ( | const Array< T > & | t | ) |
const T* get_const_ptr | ( | ) | const |
T* get_ptr | ( | ) |
void insert | ( | int | i, |
int | n | ||
) |
void insert | ( | int | i, |
int | n, | ||
const T & | t | ||
) |
void insert | ( | int | i, |
int | n, | ||
const T | t[] | ||
) |
void insert | ( | int | i, |
const Array< T > & | t | ||
) |
bool isConsistent | ( | ) | const |
Consistency check.
Definition at line 258 of file array.h.
Referenced by DataHashTable< soplex::NameSet::Name, soplex::DataKey >::isConsistent().
void remove | ( | int | n = 0 , |
int | m = 1 |
||
) |
void reSize | ( | int | newsize | ) |
reset the number of elements.
Definition at line 197 of file array.h.
Referenced by Array< soplex::UnitVectorBase * >::operator=(), and DataHashTable< soplex::NameSet::Name, soplex::DataKey >::reMax().
int size | ( | ) | const |
return the number of elements.
Definition at line 191 of file array.h.
Referenced by DataHashTable< soplex::NameSet::Name, soplex::DataKey >::add(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::autoHashSize(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::autoHashSizeold(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::clear(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::index(), Array< soplex::UnitVectorBase * >::insert(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::isConsistent(), Array< soplex::UnitVectorBase * >::operator=(), DataHashTable< soplex::NameSet::Name, soplex::DataKey >::reMax(), and Array< soplex::UnitVectorBase * >::remove().
|
protected |
Definition at line 72 of file array.h.
Referenced by Array< soplex::UnitVectorBase * >::append(), Array< soplex::UnitVectorBase * >::Array(), Array< soplex::UnitVectorBase * >::insert(), and Array< soplex::UnitVectorBase * >::operator=().