dict_delete_var__ (struct dictionary *d, struct variable *v, bool skip_callbacks)
{
int dict_index = var_get_dict_index (v);
- const int case_index = var_get_case_index (v);
assert (dict_contains_var (d, v));
if (! skip_callbacks)
{
if (d->changed) d->changed (d, d->changed_data);
- if (d->callbacks && d->callbacks->var_deleted)
- d->callbacks->var_deleted (d, v, dict_index, case_index, d->cb_data);
+ if (d->callbacks && d->callbacks->vars_deleted)
+ d->callbacks->vars_deleted (d, dict_index, 1, d->cb_data);
}
invalidate_proto (d);
dict_delete_var (struct dictionary *d, struct variable *v)
{
dict_delete_var__ (d, v, false);
+ dict_compact_values (d);
}
while (count-- > 0)
dict_delete_var (d, *vars++);
+ dict_compact_values (d);
}
/* Deletes the COUNT variables in D starting at index IDX. This
struct delvar {
struct ll ll;
struct variable *var;
- int case_index;
};
struct ll_list list = LL_INITIALIZER (list);
dict_set_filter (d, NULL);
dv->var = v;
- dv->case_index = var_get_case_index (v);
ll_push_tail (&list, (struct ll *)dv);
}
the variables. The vardict is not valid at this point
anymore. That is the reason why we stored the
caseindex before reindexing. */
+ if (d->callbacks && d->callbacks->vars_deleted)
+ d->callbacks->vars_deleted (d, idx, count, d->cb_data);
for (size_t vi = idx; vi < idx + count; vi++)
{
struct delvar *dv = (struct delvar *) ll_pop_head (&list);
var_clear_vardict (dv->var);
- if (d->callbacks && d->callbacks->var_deleted)
- d->callbacks->var_deleted (d, dv->var, vi, dv->case_index, d->cb_data);
var_unref (dv->var);
free (dv);
}
+
+ dict_compact_values (d);
}
/* Deletes scratch variables from dictionary D. */
dict_delete_var (d, d->vars[i].var);
else
i++;
+
+ dict_compact_values (d);
}
\f
return n;
}
-/* Returns the case prototype that would result after deleting
- all variables from D that are not in one of the
- EXCLUDE_CLASSES and compacting the dictionary with
- dict_compact().
-
- The caller must unref the returned caseproto when it is no
- longer needed. */
-struct caseproto *
-dict_get_compacted_proto (const struct dictionary *d,
- unsigned int exclude_classes)
-{
- struct caseproto *proto;
- size_t i;
-
- assert (!(exclude_classes & ~DC_ALL));
-
- proto = caseproto_create ();
- for (i = 0; i < d->n_vars; i++)
- {
- struct variable *v = d->vars[i].var;
- if (!(exclude_classes & var_get_dict_class (v)))
- proto = caseproto_add_width (proto, var_get_width (v));
- }
- return proto;
-}
/* Returns the file label for D, or a null pointer if D is
unlabeled (see cmd_file_label()). */
const char *