GiaNeighborCandidateList Class Reference

#include <GiaNeighborCandidateList.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 ()
 Get position of node.

Protected Attributes

std::set< NodeHandlecandidates
 contains all neighbor candidates

Member Function Documentation

uint GiaNeighborCandidateList::getSize (  ) 

Get size of candidate list.

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

void GiaNeighborCandidateList::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 GiaNeighborCandidateList::remove ( uint  position  ) 

Removes node from position.

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

void GiaNeighborCandidateList::remove ( const NodeHandle node  ) 

Removes node.

Parameters:
node Node to remove from candidate list
00052 {
00053     candidates.erase(node);
00054 }

bool GiaNeighborCandidateList::contains ( const NodeHandle node  ) 

Check if candidate list contains node.

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

const NodeHandle & GiaNeighborCandidateList::getRandomCandidate (  ) 

00084 {
00085     return get(intuniform(0, getSize()));
00086 }

const NodeHandle & GiaNeighborCandidateList::get ( uint  position  ) 

Get node from position.

Parameters:
position 
00071 {
00072     if ( position >= candidates.size() )
00073         return NodeHandle::UNSPECIFIED_NODE;
00074     else {
00075         std::set<NodeHandle>::iterator it = candidates.begin();
00076         for (uint i=0; i<position; i++) {
00077             it++;
00078         }
00079         return *it;
00080     }
00081 }

void GiaNeighborCandidateList::clear (  ) 

Get position of node.

Returns:
position of node Clear candidate list
00106 {
00107     candidates.clear();
00108 }


Member Data Documentation

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

contains all neighbor candidates


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:29 2008 for ITM OverSim by  doxygen 1.5.3