#include <NeighborCandidateList.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 () |
Clear candidate list. | |
Protected Attributes | |
std::set< NodeHandle > | candidates |
contains all neighbor candidates |
void NeighborCandidateList::add | ( | const NodeHandle & | node | ) |
Add an node to candidate list.
node | Node to add to candidate list |
00037 { 00038 assert(!(node.isUnspecified())); 00039 candidates.insert( node ); 00040 }
void NeighborCandidateList::clear | ( | ) |
bool NeighborCandidateList::contains | ( | const NodeHandle & | node | ) |
Check if candidate list contains node.
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.
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 | ( | ) |
uint NeighborCandidateList::getSize | ( | ) |
Get size of candidate list.
00031 { 00032 return candidates.size(); 00033 }
void NeighborCandidateList::remove | ( | const NodeHandle & | node | ) |
Removes node.
node | Node to remove from candidate list |
00055 { 00056 candidates.erase(node); 00057 }
void NeighborCandidateList::remove | ( | uint | position | ) |
Removes node from position.
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 }
std::set<NodeHandle> NeighborCandidateList::candidates [protected] |
contains all neighbor candidates