Previous: Inspecting User-Missing Value Sets, Up: User-Missing Values


2.3.5 Modifying User-Missing Value Sets

These functions modify the contents of struct missing_values objects.

The first set of functions applies to all sets of user-missing values:

— Function: bool mv_add_value (struct missing_values *mv, const union value *value)
— Function: bool mv_add_str (struct missing_values *mv, const char value[])
— Function: bool mv_add_num (struct missing_values *mv, double value)

Attempts to add the given discrete value to set of user-missing values mv. value must have the same width as mv. Returns true if value was successfully added, false if the set could not accept any more discrete values. (Always returns false if mv is a set of long string user-missing values.)

These functions are equivalent, except for the form in which value is provided, so you may use whichever function is most convenient.

— Function: void mv_pop_value (struct missing_values *mv, union value *value)

Removes a discrete value from mv (which must contain at least one discrete value) and stores it in value.

— Function: void mv_replace_value (struct missing_values *mv, const union value *value, int index)

Replaces the discrete value with the given index in mv (which must contain at least index + 1 discrete values) with value.

The second set of functions applies only to numeric sets of user-missing values:

— Function: bool mv_add_range (struct missing_values *mv, double low, double high)

Attempts to add a numeric range covering low...high (inclusive on both ends) to mv, which must be a numeric set of user-missing values. Returns true if the range is successful added, false on failure. Fails if mv already contains a range, or if mv contains more than one discrete value, or if low > high.

— Function: void mv_pop_range (struct missing_values *mv, double *low, double *high)

Given mv, which must be a numeric set of user-missing values that contains a range, removes that range from mv and stores its low endpoint in *low and its high endpoint in *high.