65 static_assert(!std::is_same<T, bool>::value,
66 "Since Array wraps std::vector, bool is not allowed to avoid unallowed behavior");
83 assert(n >= 0 && n <
int(data.capacity()));
89 assert(n >= 0 && n <
int(data.capacity()));
120 data.insert(data.end(), n, t);
125 data.insert(data.end(), t, t + n);
130 data.insert(data.end(), t.
data.begin(), t.
data.end());
139 data.insert(data.begin() + i - 1, n, newt);
147 data.insert(data.begin() + i - 1, n, t);
156 data.insert(data.begin() + i - 1, t, t + n);
165 data.insert(data.begin() + i - 1, t.
data.begin(), t.
data.end());
170 void remove(
int n = 0,
int m = 1)
172 assert(n <
size() && n >= 0);
176 data.erase(data.begin() + n, data.begin() + n + m);
180 data.erase(data.begin() + n, data.end());
193 return int(data.size());
199 data.resize(newsize);
222 data = std::move(rhs.data);
void append(int n, const T &t)
append n elements with value t.
Memory allocation routines.
int size() const
return the number of elements.
bool isConsistent() const
Consistency check.
const T & operator[](int n) const
reference n 'th element.
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.
void clear()
remove all elements.
void append(int n, const T t[])
append n elements from t.
Array< T > & operator=(const Array< T > &rhs)
assignment operator.
void insert(int i, const Array< T > &t)
insert all elements from p_array before i 'th element.
Array & operator=(const Array &&rhs)
T & operator[](int n)
reference n 'th element.
void insert(int i, int n, const T t[])
insert n elements from p_array before i 'th element.
const T * get_const_ptr() const
get a const C pointer to the data.
void insert(int i, int n, const T &t)
insert n elements with value t before i 'the element.
Everything should be within this namespace.
void reSize(int newsize)
reset the number of elements.
void append(const T &t)
append 1 elements with value t.
void push_back(const T &val)
Array(int n=0)
default constructor.
void append(int n)
append n uninitialized elements.
void insert(int i, int n)
insert n uninitialized elements before i 'th element.
Array(const Array &old)
copy constructor
void append(const Array< T > &t)
append all elements from p_array.