79 memcpy(o,A,
sizeof(A)); o +=
sizeof(A);
80 memcpy(o,B,
sizeof(B)); o +=
sizeof(B);
81 return reinterpret_cast<const nodeseq_t&
>(G) >> o;
88 memcpy(A,o,
sizeof(A)); o +=
sizeof(A);
89 memcpy(B,o,
sizeof(B)); o +=
sizeof(B);
91 err(
"in %s: corrupted genealogy serialization.",__func__);
94 return o >>
reinterpret_cast<nodeseq_t&
>(G);
114 err(
"in %s: cannot deserialize a NULL.",__func__);
115 PROTECT(o = AS_RAW(o));
171 int *
ell,
int *sat,
int *etype)
const;
176 void gendat (
double *tout,
int *anc,
int *lin,
177 int *sat,
int *type,
int *
deme,
178 int *index,
int *child)
const;
185 for (
const node_t *p : *
this) {
194 for (
const node_t *p : *
this) {
203 string_t
yaml (string_t tab =
"")
const;
207 string_t
newick (
bool extended =
true)
const;
217 if (size() > maxq+grace) {
218 err(
"maximum genealogy size exceeded!");
219 }
else if (size() > maxq) {
312 while (!blacks->empty()) {
313 ball_t *b = *(blacks->begin());
324 while (!blacks->empty()) {
325 ball_t *a = *(blacks->begin());
378 while (!p->empty()) {
396 if ((*j)->holds_own() && (*j)->slate >
timezero()) {
static const name_t undeme
Balls function as pointers.
name_t deme(void) const
view deme
bool is(color_t c) const
is a given ball of the given color?
void repair_roots(void)
roots are added at zero time if needed
size_t & ndeme(void)
number of demes
slate_t time(void) const
view current time.
size_t nsample(void) const
number of samples
~genealogy_t(void)
destructor
SEXP structure(void) const
R list description.
void drop_zlb(void)
drop all zero-length branches
void reuniqify(name_t shift)
shifts names to avoid overlap
void valid(void) const
check the validity of the genealogy.
genealogy_t(SEXP o)
constructor from RAW SEXP (containing binary serialization)
genealogy_t & operator=(const genealogy_t &G)
copy assignment operator
void death(ball_t *a, slate_t t)
death
SEXP lineage_count(void) const
lineage count and saturation
genealogy_t & prune(void)
prune the tree (drop all black balls)
size_t bytesize(void) const
size of serialized binary form
genealogy_t(double t0=R_NaReal, size_t ndeme=0)
string_t yaml(string_t tab="") const
human/machine-readable info
size_t ndeme(void) const
number of demes
genealogy_t(const genealogy_t &G)
copy constructor
bool check_genealogy_size(size_t grace=0) const
check the size of the genealogy (to prevent memory exhaustion).
slate_t timezero(void) const
get zero time.
ball_t * graft(slate_t t, name_t d)
graft a new lineage into deme d
void migrate(ball_t *a, slate_t t, name_t d=0)
movement into deme d
slate_t _time
The current time.
SEXP gendat(void) const
genealogy information in list format
ball_t * birth(node_t *p, name_t d)
birth of second or subsequent sibling into deme d
genealogy_t & operator+=(const genealogy_t &other)
merges two genealogies, adjusting time, t0, and ndeme as needed
size_t _ndeme
The number of demes (excluding the undeme).
void insert_zlb(void)
insert zero-length branches for samples where needed
slate_t & timezero(void)
view/set zero time.
void sample_death(ball_t *a, slate_t t)
insert a sample node and simultaneously terminate the lineage
genealogy_t(raw_t *o)
constructor from serialized binary form
slate_t & time(void)
view/set current time.
genealogy_t & parse(const string_t &s)
Parse a Newick string and create the indicated genealogy.
node_t * make_node(name_t d=undeme)
void curtail(slate_t tnew, slate_t troot)
friend raw_t * operator>>(const genealogy_t &G, raw_t *o)
binary serialization
void sample_migrate(ball_t *a, slate_t t, name_t d=0)
insert a sample node and simultaneously migrate the lineage
static const name_t magic
name_t unique(void)
get the next unique name
void sample(ball_t *a, slate_t t)
insert a sample node
slate_t _t0
The initial time.
name_t _unique
The next unique name.
size_t nroot(void) const
number of roots
genealogy_t(genealogy_t &&)=default
move constructor
ball_t * birth(ball_t *a, slate_t t, name_t d)
birth into deme d
genealogy_t & obscure(void)
erase all deme information
string_t newick(bool extended=true) const
put genealogy at current time into Newick format.
node_t * scan_branch(string_t::const_iterator b, string_t::const_iterator e)
Encodes a genealogical node.
node_t * parent(void) const
name_t deme(void) const
view deme
ball_t * green_ball(void) const
pointer to my green ball
void insert(ball_t *a)
insert a ball into the pocket of a node
bool holds_own(void) const
void sort(void)
order nodes in order of increasing time
void attach(node_t *p, node_t *q)
size_t bytesize(void) const
size of serialized binary form
void swap(ball_t *a, ball_t *b)
swap balls a and b, wherever they lie
pocket_t * colored(color_t col) const
Get all balls of a color.
void add(node_t *p, ball_t *a)
A pocket is a set of balls.
ball_t * last_ball(void) const
retrieve the last ball
bool holds(ball_t *b) const
does this node hold the given ball?
static const size_t MEMORY_MAX
std::list< node_t * >::iterator node_nit