Skip to content

Commit bf2f3ac

Browse files
committed
Add tree_pos to tsk_tree_t struct
1 parent 77faade commit bf2f3ac

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

c/tskit/trees.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4565,6 +4565,11 @@ tsk_tree_init(tsk_tree_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t
45654565
goto out;
45664566
}
45674567
}
4568+
4569+
ret = tsk_tree_position_init(&self->tree_pos, tree_sequence, 0);
4570+
if (ret != 0) {
4571+
goto out;
4572+
}
45684573
ret = tsk_tree_clear(self);
45694574
out:
45704575
return ret;
@@ -4613,6 +4618,7 @@ tsk_tree_free(tsk_tree_t *self)
46134618
tsk_safe_free(self->next_sample);
46144619
tsk_safe_free(self->num_children);
46154620
tsk_safe_free(self->edge);
4621+
tsk_tree_position_free(&self->tree_pos);
46164622
return 0;
46174623
}
46184624

c/tskit/trees.h

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ typedef struct {
111111
tsk_table_collection_t *tables;
112112
} tsk_treeseq_t;
113113

114+
typedef struct {
115+
tsk_id_t index;
116+
struct {
117+
double left;
118+
double right;
119+
} interval;
120+
struct {
121+
tsk_id_t start;
122+
tsk_id_t stop;
123+
const tsk_id_t *order;
124+
} in;
125+
struct {
126+
tsk_id_t start;
127+
tsk_id_t stop;
128+
const tsk_id_t *order;
129+
} out;
130+
tsk_id_t left_current_index;
131+
tsk_id_t right_current_index;
132+
int direction;
133+
const tsk_treeseq_t *tree_sequence;
134+
} tsk_tree_position_t;
135+
114136
/**
115137
@brief A single tree in a tree sequence.
116138
@@ -256,6 +278,7 @@ typedef struct {
256278
int direction;
257279
tsk_id_t left_index;
258280
tsk_id_t right_index;
281+
tsk_tree_position_t tree_pos;
259282
} tsk_tree_t;
260283

261284
/****************************************************************************/
@@ -1823,31 +1846,6 @@ bool tsk_tree_equals(const tsk_tree_t *self, const tsk_tree_t *other);
18231846
int tsk_diff_iter_init_from_ts(
18241847
tsk_diff_iter_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t options);
18251848

1826-
/* Temporarily putting this here to avoid problems with doxygen. Will need to
1827-
* move up the file later when it gets incorporated into the tsk_tree_t object.
1828-
*/
1829-
typedef struct {
1830-
tsk_id_t index;
1831-
struct {
1832-
double left;
1833-
double right;
1834-
} interval;
1835-
struct {
1836-
tsk_id_t start;
1837-
tsk_id_t stop;
1838-
const tsk_id_t *order;
1839-
} in;
1840-
struct {
1841-
tsk_id_t start;
1842-
tsk_id_t stop;
1843-
const tsk_id_t *order;
1844-
} out;
1845-
tsk_id_t left_current_index;
1846-
tsk_id_t right_current_index;
1847-
int direction;
1848-
const tsk_treeseq_t *tree_sequence;
1849-
} tsk_tree_position_t;
1850-
18511849
int tsk_tree_position_init(
18521850
tsk_tree_position_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t options);
18531851
int tsk_tree_position_free(tsk_tree_position_t *self);

docs/_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ sphinx:
7777
["c:identifier", "FILE"],
7878
["c:identifier", "bool"],
7979
# This is for the anonymous interval struct embedded in the tsk_tree_t.
80-
["c:identifier", "tsk_tree_t.@1"],
80+
["c:identifier", "tsk_tree_t.@4"],
8181
["c:type", "int32_t"],
8282
["c:type", "uint32_t"],
8383
["c:type", "uint64_t"],

0 commit comments

Comments
 (0)