NeighborCandidateList Class Reference

#include <NeighborCandidateList.h>

List of all members.


Detailed Description

This class is for managing of possible neighbor nodes Used for JOIN-Protocol.


Public Member Functions

uint getSize ()
 Get size of candidate list.
void add (const NodeHandle &node)
 Add an node to candidate list.
void remove (uint position)
 Removes node from position.
void remove (const NodeHandle &node)
 Removes node.
bool contains (const NodeHandle &node)
 Check if candidate list contains node.
const NodeHandlegetRandomCandidate ()
const NodeHandleget (uint position)
 Get node from position.
void clear ()
 Clear candidate list.

Protected Attributes

std::set< NodeHandlecandidates
 contains all neighbor candidates


Member Function Documentation

void NeighborCandidateList::add ( const NodeHandle node  ) 

Add an node to candidate list.

Parameters:
node Node to add to candidate list
00037 {
00038     assert(!(node.isUnspecified()));
00039     candidates.insert( node );
00040 }

void NeighborCandidateList::clear (  ) 

Clear candidate list.

00113 {
00114     candidates.clear();
00115 }

bool NeighborCandidateList::contains ( const NodeHandle node  ) 

Check if candidate list contains node.

Parameters:
node 
Returns:
true if list contains node
00060 {
00061     if(node.key.isUnspecified())
00062         return false;
00063 
00064     std::set
00065         <NodeHandle>::iterator it = candidates.find(node);
00066 
00067     if(it != candidates.end() && it->key == node.key)
00068         return true;
00069     else
00070         return false;
00071 }

const NodeHandle & NeighborCandidateList::get ( uint  position  ) 

Get node from position.

Parameters:
position 
00076 {
00077     if ( position >= candidates.size() )
00078         return NodeHandle::UNSPECIFIED_NODE;
00079     else {
00080         std::set
00081             <NodeHandle>::iterator it = candidates.begin();
00082         for (uint i=0; i<position; i++) {
00083             it++;
00084         }
00085         return *it;
00086     }
00087 }

const NodeHandle & NeighborCandidateList::getRandomCandidate (  ) 

00090 {
00091     return get
00092                (intuniform(0, getSize()));
00093 }

uint NeighborCandidateList::getSize (  ) 

Get size of candidate list.

Returns:
Size of candidate list
00031 {
00032     return candidates.size();
00033 }

void NeighborCandidateList::remove ( const NodeHandle node  ) 

Removes node.

Parameters:
node Node to remove from candidate list
00055 {
00056     candidates.erase(node);
00057 }

void NeighborCandidateList::remove ( uint  position  ) 

Removes node from position.

Parameters:
position 
00044 {
00045     std::set
00046         <NodeHandle>::iterator it = candidates.begin();
00047     for (uint i=0; i<position; i++) {
00048         it++;
00049     }
00050     candidates.erase( it );
00051 }


Member Data Documentation

std::set<NodeHandle> NeighborCandidateList::candidates [protected]

contains all neighbor candidates


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