8#include <unordered_map>
24typedef typename std::set<ball_t*,ball_order>::const_iterator
ball_it;
25typedef typename std::set<ball_t*,ball_order>::const_reverse_iterator
ball_rev_it;
30class pocket_t :
public std::set<ball_t*,ball_order> {
36 for (
ball_t *b : *
this)
delete b;
49 size_t psize = p.size();
50 memcpy(o,&psize,
sizeof(
size_t)); o +=
sizeof(size_t);
60 memcpy(&psize,o,
sizeof(
size_t)); o +=
sizeof(size_t);
61 for (
size_t i = 0; i < psize; i++) {
81 void repair_owners (
const std::unordered_map<name_t,node_t*>& node_name,
82 std::unordered_map<name_t,ball_t*> *ball_name) {
86 (*ball_name)[b->
uniq] = b;
108 for (
ball_it i = begin(); !result && i != end(); i++) {
109 result = ((*i)->color == c);
125 if (b->
color == c) a = b;
131 string_t
yaml (string_t tab =
"")
const;
Balls function as pointers.
node_t * owner(void) const
view owner of a green ball
static const size_t bytesize
size of binary serialization
node_t * holder(void) const
in whose pocket do I lie?
bool is(color_t c) const
is a given ball of the given color?
Encodes a genealogical node.
A pocket is a set of balls.
friend raw_t * operator>>(const pocket_t &p, raw_t *o)
binary serialization
void clean(void)
delete balls and clear pocket
void repair_owners(const std::unordered_map< name_t, node_t * > &node_name, std::unordered_map< name_t, ball_t * > *ball_name)
ball_t * ball(const color_t c) const
retrieve the first ball of the specified color.
SEXP structure(void) const
R list description.
bool holds(color_t c) const
does this node hold a ball of this color?
ball_t * last_ball(void) const
retrieve the last ball
void repair_holder(node_t *p)
~pocket_t(void)
destructor
size_t bytesize(void) const
size of binary serialization
string_t yaml(string_t tab="") const
human/machine-readable info
ball_t * first_ball(void) const
retrieve the first ball
bool holds(ball_t *b) const
does this node hold the given ball?
std::set< ball_t *, ball_order >::const_reverse_iterator ball_rev_it
std::set< ball_t *, ball_order >::const_iterator ball_it
Ordering for balls in pockets.
bool operator()(const ball_t *a, const ball_t *b) const