#include <NodeVector.h>
Public Types | |
typedef std::vector< T >::iterator | iterator |
typedef std::vector< T >::const_iterator | const_iterator |
Public Member Functions | |
BaseKeySortedVector (uint16_t maxSize=0, const Comparator< OverlayKey > *comparator=NULL) | |
~BaseKeySortedVector () | |
bool | isAddable (const T &element) const |
bool | isFull () const |
bool | isEmpty () const |
bool | add (const T &element) |
const T & | find (const OverlayKey &key) const |
Static Public Attributes | |
static const T | UNSPECIFIED_ELEMENT |
Private Attributes | |
const Comparator< OverlayKey > * | comparator |
uint16_t | maxSize |
typedef std::vector<T>::const_iterator BaseKeySortedVector< T, T_key >::const_iterator |
typedef std::vector<T>::iterator BaseKeySortedVector< T, T_key >::iterator |
BaseKeySortedVector< T, T_key >::BaseKeySortedVector | ( | uint16_t | maxSize = 0 , |
|
const Comparator< OverlayKey > * | comparator = NULL | |||
) | [inline] |
BaseKeySortedVector< T, T_key >::~BaseKeySortedVector | ( | ) | [inline] |
bool BaseKeySortedVector< T, T_key >::add | ( | const T & | element | ) | [inline] |
00111 { 00112 // check if handle is addable 00113 if ( isAddable(element) ) 00114 { // yes -> 00115 00116 // add handle to the appropriate position 00117 if ( ( std::vector<T>::size() != 0 ) && comparator ) 00118 { 00119 for ( iterator i = std::vector<T>::begin(); 00120 i != std::vector<T>::end(); i++ ) 00121 if ( comparator->compare(T_key::key(element), 00122 T_key::key(*i)) < 0 ) 00123 { 00124 std::vector<T>::insert( i, element ); 00125 break; 00126 } 00127 } 00128 else 00129 { 00130 push_back(element); 00131 } 00132 00133 // adjust size 00134 if ((maxSize != 0) && (std::vector<T>::size() >= maxSize)) 00135 { 00136 std::vector<T>::resize(maxSize); 00137 } 00138 00139 return true; 00140 } 00141 else 00142 { 00143 return false; 00144 } 00145 00146 };
const T& BaseKeySortedVector< T, T_key >::find | ( | const OverlayKey & | key | ) | const [inline] |
00149 { 00150 for ( const_iterator i = std::vector<T>::begin(); 00151 i != std::vector<T>::end(); i++) 00152 { 00153 if (T_key::key(*i) == key) return *i; 00154 } 00155 return UNSPECIFIED_ELEMENT; 00156 };
bool BaseKeySortedVector< T, T_key >::isAddable | ( | const T & | element | ) | const [inline] |
00094 { 00095 return ( std::vector<T>::size() != maxSize || 00096 (comparator && ( comparator->compare( T_key::key(element), 00097 T_key::key(std::vector<T>::back()) ) < 0 ))); 00098 };
bool BaseKeySortedVector< T, T_key >::isEmpty | ( | ) | const [inline] |
bool BaseKeySortedVector< T, T_key >::isFull | ( | ) | const [inline] |
const Comparator<OverlayKey>* BaseKeySortedVector< T, T_key >::comparator [private] |
uint16_t BaseKeySortedVector< T, T_key >::maxSize [private] |
const T BaseKeySortedVector< T, T_key >::UNSPECIFIED_ELEMENT [static] |