#include <NodeVector.h>
Inheritance diagram for NodeVector:
Public Member Functions | |
NodeVector (uint16_t maxSize=0, const Comparator< OverlayKey > *comparator=NULL) | |
~NodeVector () | |
bool | isAddable (const NodeHandle &handle) const |
bool | add (const NodeHandle &handle) |
Private Attributes | |
const Comparator< OverlayKey > * | comparator |
uint16_t | maxSize |
NodeVector::NodeVector | ( | uint16_t | maxSize = 0 , |
|
const Comparator< OverlayKey > * | comparator = NULL | |||
) |
bool NodeVector::add | ( | const NodeHandle & | handle | ) |
00041 { 00042 // check if handle is addable 00043 if ( isAddable(handle) ) { // yes -> 00044 00045 // add handle to the appropriate position 00046 if ( size() != 0 ) { 00047 for ( iterator i = begin(); i != end(); i++ ) 00048 if ( comparator->compare( handle.key, i->key ) < 0 ) { 00049 insert( i, handle ); 00050 break; 00051 } 00052 } else 00053 push_back(handle); 00054 00055 // adjust size 00056 if (maxSize!=0 && size()>=maxSize) 00057 resize(maxSize); 00058 00059 return true; 00060 } else 00061 return false; 00062 }
bool NodeVector::isAddable | ( | const NodeHandle & | handle | ) | const |
00034 { 00035 return ( size() != maxSize || 00036 comparator->compare( handle.key, back().key ) < 0 ); 00037 }
const Comparator<OverlayKey>* NodeVector::comparator [private] |
uint16_t NodeVector::maxSize [private] |