OverSim
GiaNeighborCandidateList Class Reference

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

#include <GiaNeighborCandidateList.h>

Public Member Functions

uint32_t getSize ()
 Get size of candidate list.
void add (const NodeHandle &node)
 Add an node to candidate list.
void remove (uint32_t 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 (uint32_t position)
 Get node from position.
void clear ()
 Get position of node.

Protected Attributes

std::set< NodeHandlecandidates
 contains all neighbor candidates

Detailed Description

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

Definition at line 35 of file GiaNeighborCandidateList.h.

Member Function Documentation

void GiaNeighborCandidateList::add ( const NodeHandle node)

Add an node to candidate list.

Parameters
nodeNode to add to candidate list

Definition at line 37 of file GiaNeighborCandidateList.cc.

Referenced by Gia::changeState(), Gia::handleTimerEvent(), and Gia::handleUDPMessage().

{
assert(!(node.isUnspecified()));
candidates.insert( node );
}
void GiaNeighborCandidateList::clear ( )

Get position of node.

Returns
position of node Clear candidate list

Definition at line 106 of file GiaNeighborCandidateList.cc.

Referenced by Gia::initializeOverlay().

{
candidates.clear();
}
bool GiaNeighborCandidateList::contains ( const NodeHandle node)

Check if candidate list contains node.

Parameters
node
Returns
true if list contains node

Definition at line 57 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleTimerEvent(), and Gia::handleUDPMessage().

{
if(node.getKey().isUnspecified())
return false;
std::set<NodeHandle>::iterator it = candidates.find(node);
if(it != candidates.end() && it->getKey() == node.getKey())
return true;
else
return false;
}
const NodeHandle & GiaNeighborCandidateList::get ( uint32_t  position)

Get node from position.

Parameters
position

Definition at line 71 of file GiaNeighborCandidateList.cc.

{
if ( position >= candidates.size() )
else {
std::set<NodeHandle>::iterator it = candidates.begin();
for (uint32_t i=0; i<position; i++) {
it++;
}
return *it;
}
}
const NodeHandle & GiaNeighborCandidateList::getRandomCandidate ( )

Definition at line 84 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleTimerEvent().

{
return get(intuniform(0, getSize()));
}
uint32_t GiaNeighborCandidateList::getSize ( )

Get size of candidate list.

Returns
Size of candidate list

Definition at line 32 of file GiaNeighborCandidateList.cc.

Referenced by getRandomCandidate(), and Gia::handleTimerEvent().

{
return candidates.size();
}
void GiaNeighborCandidateList::remove ( uint32_t  position)

Removes node from position.

Parameters
position

Definition at line 43 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleUDPMessage().

{
std::set<NodeHandle>::iterator it = candidates.begin();
for (uint32_t i=0; i<position; i++) {
it++;
}
candidates.erase( it );
}
void GiaNeighborCandidateList::remove ( const NodeHandle node)

Removes node.

Parameters
nodeNode to remove from candidate list

Definition at line 52 of file GiaNeighborCandidateList.cc.

{
candidates.erase(node);
}

Member Data Documentation

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

contains all neighbor candidates

Definition at line 89 of file GiaNeighborCandidateList.h.

Referenced by add(), clear(), contains(), get(), getSize(), and remove().


The documentation for this class was generated from the following files: