17 for(
unsigned int i = 0; i < max; i++)
19 array[i] = v.array[i];
38 FUN* new_array =
new FUN[sz];
39 for(
unsigned int i = 0; i < max; i++)
41 new_array[i] = array[i];
56 if(idx < 0 || idx >= max)
58 throw invalid_argument(
"Index out of range");
68 if(idx < 0 || idx >= max)
70 throw invalid_argument(
"Index out of range");
91 ostream& operator<<(ostream& out, const Vector<FUN>& v)
98 for(
unsigned int i = 0; i < v.length() - 1; i++)
102 out << v[v.length() - 1];
Vector()
Constructs an empty vector.
Definition: vector.hpp:3
A (very neat) vector.
Definition: vector.h:37
FUN & operator[](const unsigned int idx)
Reads an element of the vector.
Definition: vector.hpp:54
unsigned int size() const
The size of the underlying storage.
Definition: vector.hpp:85
unsigned int length() const
The number of items stored in the vector.
Definition: vector.hpp:78
~Vector()
Destructor.
Definition: vector.hpp:25
void push_back(FUN v)
Add elements to the vector.
Definition: vector.hpp:32