#include <GiaNeighborCandidateList.h>
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 NodeHandle & | getRandomCandidate () |
const NodeHandle & | get (uint position) |
Get node from position. | |
void | clear () |
Get position of node. | |
Protected Attributes | |
std::set< NodeHandle > | candidates |
contains all neighbor candidates |
uint GiaNeighborCandidateList::getSize | ( | ) |
Get size of candidate list.
Referenced by getRandomCandidate(), and Gia::handleTimerEvent().
00033 { 00034 return candidates.size(); 00035 }
void GiaNeighborCandidateList::add | ( | const NodeHandle & | node | ) |
Add an node to candidate list.
node | Node to add to candidate list |
Referenced by Gia::changeState(), Gia::handleTimerEvent(), and Gia::handleUDPMessage().
00038 { 00039 assert(!(node.isUnspecified())); 00040 candidates.insert( node ); 00041 }
void GiaNeighborCandidateList::remove | ( | uint | position | ) |
Removes node from position.
position |
Referenced by Gia::handleUDPMessage().
00044 { 00045 std::set<NodeHandle>::iterator it = candidates.begin(); 00046 for (uint i=0; i<position; i++) { 00047 it++; 00048 } 00049 candidates.erase( it ); 00050 }
void GiaNeighborCandidateList::remove | ( | const NodeHandle & | node | ) |
Removes node.
node | Node to remove from candidate list |
00053 { 00054 candidates.erase(node); 00055 }
bool GiaNeighborCandidateList::contains | ( | const NodeHandle & | node | ) |
Check if candidate list contains node.
node |
Referenced by Gia::handleTimerEvent(), and Gia::handleUDPMessage().
00058 { 00059 if(node.key.isUnspecified()) 00060 return false; 00061 00062 std::set<NodeHandle>::iterator it = candidates.find(node); 00063 00064 if(it != candidates.end() && it->key == node.key) 00065 return true; 00066 else 00067 return false; 00068 }
const NodeHandle & GiaNeighborCandidateList::getRandomCandidate | ( | ) |
const NodeHandle & GiaNeighborCandidateList::get | ( | uint | position | ) |
Get node from position.
position |
00072 { 00073 if ( position >= candidates.size() ) 00074 return NodeHandle::UNSPECIFIED_NODE; 00075 else { 00076 std::set<NodeHandle>::iterator it = candidates.begin(); 00077 for (uint i=0; i<position; i++) { 00078 it++; 00079 } 00080 return *it; 00081 } 00082 }
void GiaNeighborCandidateList::clear | ( | ) |
Get position of node.
Referenced by Gia::initializeOverlay().
00107 { 00108 candidates.clear(); 00109 }
std::set<NodeHandle> GiaNeighborCandidateList::candidates [protected] |