Skip to main content

tsk_population_table_keep_rows

Function tsk_population_table_keep_rows 

Source
pub unsafe extern "C" fn tsk_population_table_keep_rows(
    self_: *mut tsk_population_table_t,
    keep: *const tsk_bool_t,
    options: tsk_flags_t,
    id_map: *mut tsk_id_t,
) -> c_int
Available on crate feature bindings only.
Expand description

@brief Subset this table by keeping rows according to a boolean mask.

@rst Deletes rows from this table and optionally return the mapping from IDs in the current table to the updated table. Rows are kept or deleted according to the specified boolean array keep such that for each row j if keep[j] is false (zero) the row is deleted, and otherwise the row is retained. Thus, keep must be an array of at least num_rows :c:type:bool values.

If the id_map argument is non-null, this array will be updated to represent the mapping between IDs before and after row deletion. For row j, id_map[j] will contain the new ID for row j if it is retained, or :c:macro:TSK_NULL if the row has been removed. Thus, id_map must be an array of at least num_rows :c:type:tsk_id_t values.

.. warning:: C++ users need to be careful to specify the correct type when passing in values for the keep array, using std::vector<tsk_bool_t> and not std::vector<bool>, as the latter may not be correct size.

@endrst

@param self A pointer to a tsk_population_table_t object. @param keep Array of boolean flags describing whether a particular row should be kept or not. Must be at least num_rows long. @param options Bitwise option flags. Currently unused; should be set to zero to ensure compatibility with later versions of tskit. @param id_map An array in which to store the mapping between new and old IDs. If NULL, this will be ignored. @return Return 0 on success or a negative value on failure.