Function tskit::bindings::tsk_tree_get_time
source · pub unsafe extern "C" fn tsk_tree_get_time(
self_: *const tsk_tree_t,
u: tsk_id_t,
ret_time: *mut f64
) -> c_int
Expand description
@brief Returns the time of the specified node.
@rst
Equivalent to tables->nodes.time[u]
with bounds checking for the node u.
Performance sensitive code which can guarantee that the node u is
valid should use the direct array access in preference to this method,
for example:
.. code-block:: c
static void print_times(const tsk_tree_t *tree) { int ret; tsk_size_t num_nodes, j; const double *node_time = tree->tree_sequence->tables->nodes.time; tsk_id_t *nodes = malloc(tsk_tree_get_size_bound(tree) * sizeof(*nodes));
if (nodes == NULL) { errx(EXIT_FAILURE, “Out of memory”); } ret = tsk_tree_preorder(tree, nodes, &num_nodes); check_tsk_error(ret); for (j = 0; j < num_nodes; j++) { printf(“time = %f\n”, node_time[nodes[j]]); } free(nodes); }
@endrst
@param self A pointer to a tsk_tree_t object. @param u The tree node. @param ret_time A double pointer to store the returned node time. @return 0 on success or a negative value on failure.