#include <vector.h>
Public Member Functions | |
| Vector () | |
| Vector (const unsigned, const T &=T()) throw ( bad_alloc ) | |
| Vector (const Vector< T > &) throw ( bad_alloc ) | |
| ~Vector () | |
| bool | empty () const |
| unsigned | size () const |
| unsigned | capacity () const |
| void | clear () |
| void | resize (const unsigned, const T &=T()) throw ( bad_alloc ) |
| T & | at (const unsigned) const throw ( VectorEmpty, OutOfBounds ) |
| void | assign (const unsigned, const T &) throw ( VectorEmpty, OutOfBounds ) |
| void | push_back (const T &) throw ( bad_alloc ) |
| void | insert (const unsigned, const T &) throw ( bad_alloc, OutOfBounds ) |
| void | remove (const unsigned) throw ( VectorEmpty, OutOfBounds ) |
| T & | operator[] (const unsigned) const throw ( VectorEmpty, OutOfBounds ) |
| const Vector< T > & | operator= (const Vector< T > &) throw ( bad_alloc ) |
Constructor for initializing a vector to a fixed size and containing a given value.
| bad_alloc | if memory cannot be allocated. |
Copy constructor.
| bad_alloc | if memory cannot be allocated. |
| bool Vector< T >::empty | ( | ) | const |
Returns true if the vector is empty; returns false otherwise.
| unsigned Vector< T >::size | ( | ) | const |
Returns the size (i.e., the number of elements) of the vector.
| unsigned Vector< T >::capacity | ( | ) | const |
Returns the capacity of the vector, which is the number of elements that the vector can store before increasing the capacity.
| void Vector< T >::clear | ( | ) |
Removes the elements of the vector.
| void Vector< T >::resize | ( | const | unsigned, | |
| const T & | v = T() | |||
| ) | throw ( bad_alloc ) |
Resizes the vector to its new size. After allocating new memory and copy the contents of old memory, stores the value in any unassigned elements.
| newSize | the new size of the vector. | |
| v | the value for any new, unassigned elements. |
| bad_alloc | if memory cannot be allocated. |
| T & Vector< T >::at | ( | const | unsigned | ) | const throw ( VectorEmpty, OutOfBounds ) |
Returns a reference to the object stored at a given position in the vector.
| i | the object's location. |
| VectorEmpty | if vector is empty. | |
| OutOfBounds | if index parameter is out of bounds. |
| void Vector< T >::assign | ( | const | unsigned, | |
| const T & | object | |||
| ) | throw ( VectorEmpty, OutOfBounds ) |
Assigns the object to the specified position in the vector.
| i | the position to be assigned. | |
| object | the object to be stored in the vector. |
| VectorEmpty | if vector is empty. | |
| OutOfBounds | if index parameter is out of bounds. |
| void Vector< T >::push_back | ( | const T & | object | ) | throw ( bad_alloc ) |
Adds the object to the end of the vector. Increases capacity if necessary.
| object | the object to be added to the end of the vector. |
| bad_alloc | if memory cannot be allocated. |
| void Vector< T >::insert | ( | const | unsigned, | |
| const T & | object | |||
| ) | throw ( bad_alloc, OutOfBounds ) |
Inserts the object at the given position. Increases capacity if necessary.
| i | the position of insertion. | |
| object | the object to be inserted. |
| bad_alloc | if memory cannot be allocated. | |
| OutOfBounds | if index parameter is out of bounds. |
| void Vector< T >::remove | ( | const | unsigned | ) | throw ( VectorEmpty, OutOfBounds ) |
Removes the object stored in the given position.
| i | the position of removal. |
| VectorEmpty | if vector is empty. | |
| OutOfBounds | if index parameter is out of bounds. |
| T & Vector< T >::operator[] | ( | const | unsigned | ) | const throw ( VectorEmpty, OutOfBounds ) |
Returns a reference to the object stored at a given position in the vector.
| i | the object's location. |
| VectorEmpty | if vector is empty. | |
| OutOfBounds | if index parameter is out of bounds. |
| const Vector< T > & Vector< T >::operator= | ( | const Vector< T > & | v | ) | throw ( bad_alloc ) |
Returns a deep copy of the vector passed in as the parameter.
| vector | the vector to be copied. |
| bad_alloc | if memory cannot be allocated. |
1.5.1