#include <NodeCollection.h>
A node collection is templated on a node type, which is a class that contains a reference to the node. It is sorted on the MaceKey referring to the node, but contains a variety of other elements.
It is like a set because it is a collection of objects, but like a map in that each object has an associated (and internal) key, the node MaceKey.
In its implementation, it maintains a NodeSet to make several of the calls more efficient, and is backed by a std::map because it is more convenient. The basic iterator methods return a std::map-like iterator from the base class, though there is also a method to return an std::set-like iterator setBegin(), setEnd(), and setFind(). Finally, for the Java fans among us, it includes a mapIterator() method which returns a MapIterator iterator.
NodeCollections also contain a MaxSize (which defaults to UINT_MAX)
Definition at line 83 of file NodeCollection.h.
Public Member Functions | |
size_t | maxSize () const |
returns the maximum number elements in the collection | |
size_t | maxsize () const |
lower case version of maxSize() | |
bool | contains (const MaceKey &who) const |
returns true if the collection contains an element referring to who | |
bool | containsKey (const MaceKey &who) const |
equivalent to contains(who) | |
NodeType & | get (const MaceKey &who) |
get the element associated with who , aborting if the element is not in the case | |
const NodeType & | get (const MaceKey &who) const |
get the element associated with who , aborting if the element is not in the case | |
NodeType & | add (const MaceKey &who) |
add a new element for node who , returning a reference to the added element. (returns an existing element if found) | |
NodeType & | add (const NodeType &nbr) |
adds the element nbr to the collection. If already in the collection, updates the value to nbr | |
void | clear () |
removes all elements from the collection | |
size_type | erase (const MaceKey &who) |
erases the element with node who | |
size_type | erase (const NodeType &who) |
erases the element corresponding to the node who is associated with | |
template<typename S> | |
bool | query (S(NodeType::*val)(void), S v) |
checks to see if a function result of an element matches the value v | |
template<typename S> | |
iterator | find (S(NodeType::*val)(void), S v) |
returns an iterator to end() or an element which matches the value v | |
template<typename S> | |
const_iterator | find (S(NodeType::*val)(void), S v) const |
returns an iterator to end() or an element which matches the value v | |
template<typename ScoreType> | |
NodeType & | leastScore (ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) |
returns the element with the lowest score (based on the score function) | |
template<typename ScoreType, typename Compare> | |
NodeType & | leastScore (const Compare &c, ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) |
returns the element with the lowest score (based on the score function and provided comparitor) | |
template<typename ScoreType> | |
const NodeType & | leastScore (ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) const |
returns the element with the lowest score (based on the score function) | |
template<typename ScoreType, typename Compare> | |
const NodeType & | leastScore (const Compare &c, ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) const |
returns the element with the lowest score (based on the score function and provided comparitor) | |
template<typename ScoreType> | |
NodeType & | greatestScore (ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) |
returns the element with the greatest score (based on the score function) | |
template<typename ScoreType, typename Compare> | |
NodeType & | greatestScore (const Compare &c, ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) |
returns the element with the greatest score (based on the score function and comparitor) | |
template<typename ScoreType> | |
const NodeType & | greatestScore (ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) const |
returns the element with the greatest score (based on the score function) | |
template<typename ScoreType, typename Compare> | |
const NodeType & | greatestScore (const Compare &c, ScoreType(NodeType::*sc)(void) const =&NodeType::getScore) const |
returns the element with the greatest score (based on the score function and comparitor) | |
NodeType & | random () |
const NodeType & | random () const |
const NodeSet & | nodeSet () const |
returns a node set reference of the nodes represented in the collection | |
bool | space () const |
return true if the collection has room for more elements | |
bool | full () const |
return true if the collection is full | |
map_iterator | mapIterator (const MaceKey *b=NULL, const MaceKey *e=NULL) |
return a map iterator of the collection, with optional start and end MaceKey objects | |
const_map_iterator | mapIterator (const MaceKey *b=NULL, const MaceKey *e=NULL) const |
return a map iterator of the collection, with optional start and end MaceKey objects | |
void | serialize (std::string &str) const |
Encode the current object at the end of str as a bytestring in a compact format (and which doesn't require delimiters to parse). | |
int | deserialize (std::istream &in) throw (SerializationException) |
Replace the current object value from the bytes read from in , returning the number of bytes read. | |
void | serializeXML_RPC (std::string &str) const throw (SerializationException) |
serialize this object onto the end of str in XML_RPC format | |
int | deserializeXML_RPC (std::istream &in) throw (SerializationException) |
deserialize this object from XML_RPC format from in | |
const std::string & | getTypeName () const |
returns the actual type parameters as strings at runtime | |
set_iterator | setBegin () |
a set_iterator version of begin() | |
const_set_iterator | setBegin () const |
a set_iterator version of begin() | |
set_iterator | setEnd () |
a set_iterator version of end() | |
const_set_iterator | setEnd () const |
a set_iterator version of end() | |
set_iterator | setFind (const MaceKey &item) |
a set_iterator version of find() | |
const_set_iterator | setFind (const MaceKey &item) const |
a set_iterator version of find() |
bool mace::NodeCollection< NodeType, MaxSize >::query | ( | S(NodeType::*)(void) | val, | |
S | v | |||
) | [inline] |
checks to see if a function result of an element matches the value v
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which returns something that can be compared here.
So if there is a function NodeType::getBlockCount(), you could call query(getBlockCount, 5), and it would return true if some element's getBlockCount method returned the value 5.
val | a function of the NodeType which returns type S | |
v | a value of type S |
Definition at line 233 of file NodeCollection.h.
iterator mace::NodeCollection< NodeType, MaxSize >::find | ( | S(NodeType::*)(void) | val, | |
S | v | |||
) | [inline] |
returns an iterator to end() or an element which matches the value v
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which returns something that can be compared here.
So if there is a function NodeType::getBlockCount(), you could call query(&NodeType::getBlockCount, 5), and it would return an iterator to some element whose getBlockCount method returned the value 5.
val | a function of the NodeType which returns type S | |
v | a value of type S |
Definition at line 258 of file NodeCollection.h.
Referenced by mace::NodeCollection< mace::AddressCacheEntry, MAX_CACHE_SIZE >::setFind().
const_iterator mace::NodeCollection< NodeType, MaxSize >::find | ( | S(NodeType::*)(void) | val, | |
S | v | |||
) | const [inline] |
returns an iterator to end() or an element which matches the value v
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which returns something that can be compared here.
So if there is a function NodeType::getBlockCount(), you could call query(&NodeType::getBlockCount, 5), and it would return an iterator to some element whose getBlockCount method returned the value 5.
val | a function of the NodeType which returns type S | |
v | a value of type S |
Definition at line 283 of file NodeCollection.h.
NodeType& mace::NodeCollection< NodeType, MaxSize >::leastScore | ( | ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore |
) | [inline] |
returns the element with the lowest score (based on the score function)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 307 of file NodeCollection.h.
Referenced by mace::AddressCache::insert().
NodeType& mace::NodeCollection< NodeType, MaxSize >::leastScore | ( | const Compare & | c, | |
ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore | |||
) | [inline] |
returns the element with the lowest score (based on the score function and provided comparitor)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
c | the comparitor to use to compare scores | |
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 349 of file NodeCollection.h.
const NodeType& mace::NodeCollection< NodeType, MaxSize >::leastScore | ( | ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore |
) | const [inline] |
returns the element with the lowest score (based on the score function)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 390 of file NodeCollection.h.
const NodeType& mace::NodeCollection< NodeType, MaxSize >::leastScore | ( | const Compare & | c, | |
ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore | |||
) | const [inline] |
returns the element with the lowest score (based on the score function and provided comparitor)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
c | the comparitor to use to compare scores | |
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 432 of file NodeCollection.h.
NodeType& mace::NodeCollection< NodeType, MaxSize >::greatestScore | ( | ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore |
) | [inline] |
returns the element with the greatest score (based on the score function)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 473 of file NodeCollection.h.
NodeType& mace::NodeCollection< NodeType, MaxSize >::greatestScore | ( | const Compare & | c, | |
ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore | |||
) | [inline] |
returns the element with the greatest score (based on the score function and comparitor)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
c | the comparitor to use to compare scores | |
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 510 of file NodeCollection.h.
const NodeType& mace::NodeCollection< NodeType, MaxSize >::greatestScore | ( | ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore |
) | const [inline] |
returns the element with the greatest score (based on the score function)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 546 of file NodeCollection.h.
const NodeType& mace::NodeCollection< NodeType, MaxSize >::greatestScore | ( | const Compare & | c, | |
ScoreType(NodeType::*)(void) const | sc = &NodeType::getScore | |||
) | const [inline] |
returns the element with the greatest score (based on the score function and comparitor)
Auto-generated node types have auto-generated get methods which can be passed to the query function. Additionally, they have a getScore function which by default is compared here.
c | the comparitor to use to compare scores | |
sc | the score function to use, defaults to &NodeType::getScore |
Definition at line 583 of file NodeCollection.h.
NodeType& mace::NodeCollection< NodeType, MaxSize >::random | ( | ) | [inline] |
Return a random element reference
Definition at line 606 of file NodeCollection.h.
Referenced by mace::NodeCollection< mace::AddressCacheEntry, MAX_CACHE_SIZE >::greatestScore(), and mace::NodeCollection< mace::AddressCacheEntry, MAX_CACHE_SIZE >::leastScore().
const NodeType& mace::NodeCollection< NodeType, MaxSize >::random | ( | ) | const [inline] |
Return a random element const reference
Definition at line 621 of file NodeCollection.h.