- int i;
- for (i = 0 ; i < d->n_vars ; ++i)
- {
- const struct variable *v = d->vars[i].var;
- printf ("Name: %s;\tdict_idx: %zu; case_idx: %zu\n",
- var_get_name (v),
- var_get_dict_index (v),
- var_get_case_index (v));
-
- }
+ for (size_t i = 0; i < d->n_vars; ++i)
+ printf ("%zu: %s\n", i, var_get_name (d->vars[i].var));
for (size_t j = 0; j < var_get_n_short_names (sv); j++)
var_set_short_name (dv, j, var_get_short_name (sv, j));
for (size_t j = 0; j < var_get_n_short_names (sv); j++)
var_set_short_name (dv, j, var_get_short_name (sv, j));
dict_delete_var (struct dictionary *d, struct variable *v)
{
dict_delete_var__ (d, v, false);
dict_delete_var (struct dictionary *d, struct variable *v)
{
dict_delete_var__ (d, v, false);
- /* We need to store the variable and the corresponding case_index
- for the delete callbacks later. We store them in a linked list.*/
- struct delvar {
- struct ll ll;
- struct variable *var;
- };
- struct ll_list list = LL_INITIALIZER (list);
+ struct variable **vars = xnmalloc (count, sizeof *vars);
dict_unset_split_var (d, v, false);
dict_unset_mrset_var (d, v);
dict_unset_split_var (d, v, false);
dict_unset_mrset_var (d, v);
/* Now issue the variable delete callbacks and delete
the variables. The vardict is not valid at this point
/* Now issue the variable delete callbacks and delete
the variables. The vardict is not valid at this point
if (d->callbacks && d->callbacks->vars_deleted)
d->callbacks->vars_deleted (d, idx, count, d->cb_data);
if (d->callbacks && d->callbacks->vars_deleted)
d->callbacks->vars_deleted (d, idx, count, d->cb_data);
hmap_insert (&d->name_map, &vardict->name_node,
utf8_hash_case_string (var_get_name (v), 0));
hmap_insert (&d->name_map, &vardict->name_node,
utf8_hash_case_string (var_get_name (v), 0));
var_set_vardict (v, vardict);
if (d->changed) d->changed (d, d->changed_data);
var_set_vardict (v, vardict);
if (d->changed) d->changed (d, d->changed_data);
-static struct variable *
-add_var (struct dictionary *d, struct variable *v)
-{
- return add_var_with_case_index (d, v, dict_get_n_vars (d));
-}
-
/* Creates and returns a new variable in D with the given NAME
and WIDTH. Returns a null pointer if the given NAME would
duplicate that of an existing variable in the dictionary. */
/* Creates and returns a new variable in D with the given NAME
and WIDTH. Returns a null pointer if the given NAME would
duplicate that of an existing variable in the dictionary. */
-struct variable *
-dict_clone_var_in_place_assert (struct dictionary *d,
- const struct variable *old_var)
-{
- assert (dict_lookup_var (d, var_get_name (old_var)) == NULL);
- return add_var_with_case_index (d, var_clone (old_var),
- var_get_case_index (old_var));
-}
-
/* Returns the variable named NAME in D, or a null pointer if no
variable has that name. */
struct variable *
/* Returns the variable named NAME in D, or a null pointer if no
variable has that name. */
struct variable *
unindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1);
move_element (d->vars, d->n_vars, sizeof *d->vars, old_index, new_index);
reindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1, false);
unindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1);
move_element (d->vars, d->n_vars, sizeof *d->vars, old_index, new_index);
reindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1, false);
{
short int *widths = xnmalloc (d->n_vars, sizeof *widths);
for (size_t i = 0; i < d->n_vars; i++)
{
short int *widths = xnmalloc (d->n_vars, sizeof *widths);
for (size_t i = 0; i < d->n_vars; i++)
- widths[i] = -1;
- for (size_t i = 0; i < d->n_vars; i++)
- {
- const struct variable *var = d->vars[i].var;
- size_t case_idx = var_get_case_index (var);
- assert (case_idx < d->n_vars);
- assert (widths[case_idx] == -1);
- widths[case_idx] = var_get_width (var);
- }
-
+ widths[i] = var_get_width (d->vars[i].var);
-/* Reassigns values in dictionary D so that fragmentation is
- eliminated. */
-void
-dict_compact_values (struct dictionary *d)
-{
- for (size_t i = 0; i < d->n_vars; i++)
- {
- struct variable *v = d->vars[i].var;
- set_var_case_index (v, i);
- }
- invalidate_proto (d);
-}
-
/* Returns the number of values occupied by the variables in
dictionary D. All variables are considered if EXCLUDE_CLASSES
is 0, or it may contain one or more of DC_ORDINARY, DC_SYSTEM,
/* Returns the number of values occupied by the variables in
dictionary D. All variables are considered if EXCLUDE_CLASSES
is 0, or it may contain one or more of DC_ORDINARY, DC_SYSTEM,