Skip to content

Commit 2838a69

Browse files
duncanMRmergify[bot]
authored andcommitted
Add tree_pos to tsk_tree_t struct
1 parent 813e361 commit 2838a69

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
@@ -4622,6 +4622,11 @@ tsk_tree_init(tsk_tree_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t
46224622
goto out;
46234623
}
46244624
}
4625+
4626+
ret = tsk_tree_position_init(&self->tree_pos, tree_sequence, 0);
4627+
if (ret != 0) {
4628+
goto out;
4629+
}
46254630
ret = tsk_tree_clear(self);
46264631
out:
46274632
return ret;
@@ -4670,6 +4675,7 @@ tsk_tree_free(tsk_tree_t *self)
46704675
tsk_safe_free(self->next_sample);
46714676
tsk_safe_free(self->num_children);
46724677
tsk_safe_free(self->edge);
4678+
tsk_tree_position_free(&self->tree_pos);
46734679
return 0;
46744680
}
46754681

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
/****************************************************************************/
@@ -1821,31 +1844,6 @@ bool tsk_tree_equals(const tsk_tree_t *self, const tsk_tree_t *other);
18211844
int tsk_diff_iter_init_from_ts(
18221845
tsk_diff_iter_t *self, const tsk_treeseq_t *tree_sequence, tsk_flags_t options);
18231846

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