#include <NodeVector.h>
Public Types | |
typedef vector< T >::iterator | iterator |
iterator for this vector | |
typedef vector< T >::const_iterator | const_iterator |
read-only iterator for this vector | |
Public Member Functions | |
BaseKeySortedVector (uint16_t maxSize=0, const Comparator< OverlayKey > *comparator=NULL) | |
constructor | |
~BaseKeySortedVector () | |
destructor | |
bool | isAddable (const T &element) const |
indicates if an object of type T can be added to the NodeVector | |
bool | isFull () const |
indicates if NodeVector holds maxSize nodes | |
bool | isEmpty () const |
indicates if NodeVector holds at least one node | |
bool | add (const T &element) |
adds an element of type T in increasing order to the NodeVector | |
const bool | contains (const OverlayKey &key) const |
Searches for an OverlayKey in NodeVector and returns true, if it is found. | |
const T & | find (const OverlayKey &key) const |
searches for an OverlayKey in NodeVector | |
iterator | findIterator (const OverlayKey &key) |
Searches for an OberlayKey in a NodeVector and returns an appropriate iterator. | |
void | downsizeTo (const uint maxElements) |
Downsize the vector to a maximum of maxElements. | |
Static Public Attributes | |
static const T | UNSPECIFIED_ELEMENT |
unspecified element of type T | |
Private Attributes | |
const Comparator< OverlayKey > * | comparator |
the OverlayKey Comparator for this vector | |
uint16_t | maxSize |
maximum nodes this vector holds |
typedef vector<T>::iterator BaseKeySortedVector< T, T_key >::iterator |
iterator for this vector
typedef vector<T>::const_iterator BaseKeySortedVector< T, T_key >::const_iterator |
read-only iterator for this vector
BaseKeySortedVector< T, T_key >::BaseKeySortedVector | ( | uint16_t | maxSize = 0 , |
|
const Comparator< OverlayKey > * | comparator = NULL | |||
) | [inline] |
constructor
maxSize | maximum nodes this vector holds | |
comparator | OverlayKey Comparator for this vector |
00085 : 00086 vector<T>(), 00087 comparator(comparator), 00088 maxSize(maxSize) {};
BaseKeySortedVector< T, T_key >::~BaseKeySortedVector | ( | ) | [inline] |
bool BaseKeySortedVector< T, T_key >::isAddable | ( | const T & | element | ) | const [inline] |
indicates if an object of type T can be added to the NodeVector
element | the element to add |
00110 { 00111 if (maxSize == 0) { 00112 return false; 00113 } 00114 00115 return( vector<T>::size() != maxSize || 00116 (comparator && ( comparator->compare( T_key::key(element), 00117 T_key::key(vector<T>::back()) ) < 0 ))); 00118 };
bool BaseKeySortedVector< T, T_key >::isFull | ( | ) | const [inline] |
indicates if NodeVector holds maxSize nodes
00126 { 00127 return(vector<T>::size() == maxSize); 00128 };
bool BaseKeySortedVector< T, T_key >::isEmpty | ( | ) | const [inline] |
bool BaseKeySortedVector< T, T_key >::add | ( | const T & | element | ) | [inline] |
adds an element of type T in increasing order to the NodeVector
element | the element to add |
00147 { 00148 // check if handle is addable 00149 if ( isAddable(element) ) { // yes -> 00150 00151 // add handle to the appropriate position 00152 if ( ( vector<T>::size() != 0 ) && comparator ) { 00153 iterator i; 00154 for ( i = vector<T>::begin(); 00155 i != vector<T>::end(); i++ ) 00156 if ( comparator->compare(T_key::key(element), 00157 T_key::key(*i)) < 0 ) { 00158 vector<T>::insert( i, element ); 00159 break; 00160 } 00161 if (i == vector<T>::end()) { 00162 push_back(element); 00163 } 00164 } else { 00165 push_back(element); 00166 } 00167 00168 // adjust size 00169 if ((maxSize != 0) && (vector<T>::size() > maxSize)) { 00170 vector<T>::resize(maxSize); 00171 } 00172 00173 return true; 00174 } else { 00175 return false; 00176 } 00177 00178 };
const bool BaseKeySortedVector< T, T_key >::contains | ( | const OverlayKey & | key | ) | const [inline] |
Searches for an OverlayKey in NodeVector and returns true, if it is found.
key | the OverlayKey to find |
00187 { 00188 for ( const_iterator i = vector<T>::begin(); 00189 i != vector<T>::end(); i++) { 00190 if (T_key::key(*i) == key) return true; 00191 } 00192 return false; 00193 }
const T& BaseKeySortedVector< T, T_key >::find | ( | const OverlayKey & | key | ) | const [inline] |
searches for an OverlayKey in NodeVector
key | the OverlayKey to find |
00203 { 00204 for ( const_iterator i = vector<T>::begin(); 00205 i != vector<T>::end(); i++) { 00206 if (T_key::key(*i) == key) return *i; 00207 } 00208 return UNSPECIFIED_ELEMENT; 00209 };
iterator BaseKeySortedVector< T, T_key >::findIterator | ( | const OverlayKey & | key | ) | [inline] |
Searches for an OberlayKey in a NodeVector and returns an appropriate iterator.
key | The key to search |
00219 { 00220 iterator i; 00221 for ( i = vector<T>::begin(); i != vector<T>::end(); i++) 00222 if (T_key::key(*i) == key) break; 00223 return i; 00224 }
void BaseKeySortedVector< T, T_key >::downsizeTo | ( | const uint | maxElements | ) | [inline] |
const Comparator<OverlayKey>* BaseKeySortedVector< T, T_key >::comparator [private] |
the OverlayKey Comparator for this vector
uint16_t BaseKeySortedVector< T, T_key >::maxSize [private] |
maximum nodes this vector holds
const T BaseKeySortedVector< T, T_key >::UNSPECIFIED_ELEMENT [static] |
unspecified element of type T