NodeVector Class Reference

#include <NodeVector.h>

Inheritance diagram for NodeVector:

Bucket List of all members.

Detailed Description

A NodeHandle STL-vector that supports sorted node inserts.

Author:
Sebastian Mies


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


Constructor & Destructor Documentation

NodeVector::NodeVector ( uint16_t  maxSize = 0,
const Comparator< OverlayKey > *  comparator = NULL 
)

00025 {
00026     this->maxSize = maxSize;
00027     this->comparator = comparator;
00028 }

NodeVector::~NodeVector (  ) 

00031 {}


Member Function Documentation

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 }


Member Data Documentation

const Comparator<OverlayKey>* NodeVector::comparator [private]

uint16_t NodeVector::maxSize [private]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7