#include <vector.hpp>
Public Member Functions | |
| VECTOR () | |
| Default Constructor. More... | |
| VECTOR (int initialCapacity) | |
| Constructor with initial capacity as Vector size. More... | |
| VECTOR (const VECTOR ©) | |
| Copy Constructor. More... | |
| VECTOR & | operator= (const VECTOR ©) |
| =Operator to copy the vector. More... | |
| ~VECTOR () | |
| Destructor of the vector. More... | |
| const TYPE & | front () |
| const TYPE & | back () |
| const TYPE & | pop_front () |
| Pops & returns the first(oldest) element of the vector (index 0). (SLOW) More... | |
| const TYPE & | pop_back () |
| Pops & returns the last element from the vector. (FAST) More... | |
| void | push_back (const TYPE &element) |
| Pushes the element to the end of the vector. (FAST) More... | |
| void | push_front (const TYPE &element) |
| Pushes the element at the 1st location (index 0). (SLOW) More... | |
| void | reverse () |
| Reverses the order of the vector contents. More... | |
| const TYPE & | rotateRight () |
| Rotates the vector right by 1 and. More... | |
| const TYPE & | rotateLeft () |
| Rotates the vector left by 1 and. More... | |
| const TYPE & | eraseAt (unsigned int pos) |
| Erases the element at pos and returns it. All elements are shifted left from this pos. More... | |
| int | getFirstIndexOf (const TYPE &find) |
| bool | remove (const TYPE &element) |
| Removes the first Vector Element match from this vector,. More... | |
| int | removeAll (const TYPE &element) |
| Removes all Vector Elements that match the given element,. More... | |
| bool | replace (const TYPE &find, const TYPE &replace) |
| Replaces the first element "find" and replaces it with "replace". More... | |
| int | replaceAll (const TYPE &find, const TYPE &replace) |
| Replaces all instances of "find" and replaces it with "replace". More... | |
| void | fill (const TYPE &fillElement) |
| Fills the entire vector capacity with the given fillElement. More... | |
| void | fillUnused (const TYPE &fillElement) |
| Fills the unused capacity of the vector with the given fillElement. More... | |
| unsigned int | size () const |
| unsigned int | capacity () const |
| void | reserve (unsigned int size) |
| Reserves the memory for the vector up front. More... | |
| void | setGrowthFactor (int factor) |
| Changes the size the vector grows by. More... | |
| void | clear () |
| Clears the entire vector. More... | |
| bool | isEmpty () |
| TYPE & | at (const unsigned int i) |
| Access element at given index. More... | |
| TYPE & | operator[] (const unsigned int i) |
| [] Operator for Left-hand-side. More... | |
| const TYPE & | operator[] (const unsigned int i) const |
| [] Operator of Right-hand-side. More... | |
| void | operator+= (const TYPE &item) |
| += Operator which is same as push_back() of an item More... | |
Detailed Description
template<typename TYPE>
class VECTOR< TYPE >
Vector class
This vector class can by used as a dynamic array. This can provide fast-index based retrieval of stored elements and also provides fast methods to erase or rotate the elements. The underlining storage uses pointer-based storage and entire objects are not created or deleted when the vector contents change.
Usage:
Constructor & Destructor Documentation
Constructor with initial capacity as Vector size.
Member Function Documentation
| TYPE & VECTOR< TYPE >::at | ( | const unsigned int | i | ) |
Access element at given index.
| const TYPE & VECTOR< TYPE >::back | ( | ) |
- Returns
- the last added element of the vector.
| unsigned int VECTOR< TYPE >::capacity | ( | void | ) | const |
- Returns
- The capacity of the vector (allocated memory)
| void VECTOR< TYPE >::clear | ( | void | ) |
Clears the entire vector.
| const TYPE & VECTOR< TYPE >::eraseAt | ( | unsigned int | pos | ) |
Erases the element at pos and returns it. All elements are shifted left from this pos.
| void VECTOR< TYPE >::fill | ( | const TYPE & | fillElement | ) |
Fills the entire vector capacity with the given fillElement.
| void VECTOR< TYPE >::fillUnused | ( | const TYPE & | fillElement | ) |
Fills the unused capacity of the vector with the given fillElement.
| const TYPE & VECTOR< TYPE >::front | ( | ) |
- Returns
- the first(oldest) element of the vector (index 0).
| int VECTOR< TYPE >::getFirstIndexOf | ( | const TYPE & | find | ) |
- Returns
- the first index at which the element find is located at
| bool VECTOR< TYPE >::isEmpty | ( | ) |
- Returns
- True if the vector is empty
|
inline |
+= Operator which is same as push_back() of an item
=Operator to copy the vector.
| TYPE & VECTOR< TYPE >::operator[] | ( | const unsigned int | i | ) |
[] Operator for Left-hand-side.
| const TYPE & VECTOR< TYPE >::operator[] | ( | const unsigned int | i | ) | const |
[] Operator of Right-hand-side.
| const TYPE & VECTOR< TYPE >::pop_back | ( | ) |
Pops & returns the last element from the vector. (FAST)
| const TYPE & VECTOR< TYPE >::pop_front | ( | void | ) |
Pops & returns the first(oldest) element of the vector (index 0). (SLOW)
| void VECTOR< TYPE >::push_back | ( | const TYPE & | element | ) |
Pushes the element to the end of the vector. (FAST)
| void VECTOR< TYPE >::push_front | ( | const TYPE & | element | ) |
Pushes the element at the 1st location (index 0). (SLOW)
| bool VECTOR< TYPE >::remove | ( | const TYPE & | element | ) |
Removes the first Vector Element match from this vector,.
- Returns
- true if successful
| int VECTOR< TYPE >::removeAll | ( | const TYPE & | element | ) |
Removes all Vector Elements that match the given element,.
- Returns
- number of elements removed
| bool VECTOR< TYPE >::replace | ( | const TYPE & | find, |
| const TYPE & | replace | ||
| ) |
Replaces the first element "find" and replaces it with "replace".
| int VECTOR< TYPE >::replaceAll | ( | const TYPE & | find, |
| const TYPE & | replace | ||
| ) |
Replaces all instances of "find" and replaces it with "replace".
| void VECTOR< TYPE >::reserve | ( | unsigned int | size | ) |
Reserves the memory for the vector up front.
| void VECTOR< TYPE >::reverse | ( | ) |
Reverses the order of the vector contents.
| const TYPE & VECTOR< TYPE >::rotateLeft | ( | ) |
Rotates the vector left by 1 and.
- Returns
- front() value
| const TYPE & VECTOR< TYPE >::rotateRight | ( | ) |
Rotates the vector right by 1 and.
- Returns
- front() value
| void VECTOR< TYPE >::setGrowthFactor | ( | int | factor | ) |
Changes the size the vector grows by.
| unsigned int VECTOR< TYPE >::size | ( | void | ) | const |
- Returns
- The size of the vector (actual usage)
The documentation for this class was generated from the following file:
- /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L3_Utils/vector.hpp

1.8.11