These assertions are already effectively checked anyhow, since the program
will already segfault if passed a null pointer.
struct dictionary *d;
size_t i;
struct dictionary *d;
size_t i;
d = dict_create ();
for (i = 0; i < s->var_cnt; i++)
d = dict_create ();
for (i = 0; i < s->var_cnt; i++)
{
/* FIXME? Should we really clear case_limit, label, documents?
Others are necessarily cleared by deleting all the variables.*/
{
/* FIXME? Should we really clear case_limit, label, documents?
Others are necessarily cleared by deleting all the variables.*/
while (d->var_cnt > 0 )
{
dict_delete_var (d, d->var[d->var_cnt - 1]);
while (d->var_cnt > 0 )
{
dict_delete_var (d, d->var[d->var_cnt - 1]);
for (i = 0; i < d->var_cnt; i++)
var_clear_aux (d->var[i]);
}
for (i = 0; i < d->var_cnt; i++)
var_clear_aux (d->var[i]);
}
size_t
dict_get_var_cnt (const struct dictionary *d)
{
size_t
dict_get_var_cnt (const struct dictionary *d)
{
struct variable *
dict_get_var (const struct dictionary *d, size_t idx)
{
struct variable *
dict_get_var (const struct dictionary *d, size_t idx)
{
assert (idx < d->var_cnt);
return d->var[idx];
assert (idx < d->var_cnt);
return d->var[idx];
- assert (d != NULL);
- assert (vars != NULL);
- assert (cnt != NULL);
assert (exclude == (exclude & DC_ALL));
count = 0;
assert (exclude == (exclude & DC_ALL));
count = 0;
{
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
{
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
assert (count == 0 || vars != NULL);
while (count-- > 0)
assert (count == 0 || vars != NULL);
while (count-- > 0)
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
/* FIXME: this can be done in O(count) time, but this algorithm
is O(count**2). */
for (i = 0; i < d->var_cnt; )
if (var_get_dict_class (d->var[i]) == DC_SCRATCH)
dict_delete_var (d, d->var[i]);
for (i = 0; i < d->var_cnt; )
if (var_get_dict_class (d->var[i]) == DC_SCRATCH)
dict_delete_var (d, d->var[i]);
struct variable **new_var;
size_t i;
struct variable **new_var;
size_t i;
assert (count == 0 || order != NULL);
assert (count <= d->var_cnt);
assert (count == 0 || order != NULL);
assert (count <= d->var_cnt);
struct variable *
dict_get_weight (const struct dictionary *d)
{
struct variable *
dict_get_weight (const struct dictionary *d)
{
assert (d->weight == NULL || dict_contains_var (d, d->weight));
return d->weight;
assert (d->weight == NULL || dict_contains_var (d, d->weight));
return d->weight;
dict_get_case_weight (const struct dictionary *d, const struct ccase *c,
bool *warn_on_invalid)
{
dict_get_case_weight (const struct dictionary *d, const struct ccase *c,
bool *warn_on_invalid)
{
assert (c != NULL);
if (d->weight == NULL)
assert (c != NULL);
if (d->weight == NULL)
void
dict_set_weight (struct dictionary *d, struct variable *v)
{
void
dict_set_weight (struct dictionary *d, struct variable *v)
{
assert (v == NULL || dict_contains_var (d, v));
assert (v == NULL || var_is_numeric (v));
assert (v == NULL || dict_contains_var (d, v));
assert (v == NULL || var_is_numeric (v));
struct variable *
dict_get_filter (const struct dictionary *d)
{
struct variable *
dict_get_filter (const struct dictionary *d)
{
assert (d->filter == NULL || dict_contains_var (d, d->filter));
return d->filter;
assert (d->filter == NULL || dict_contains_var (d, d->filter));
return d->filter;
void
dict_set_filter (struct dictionary *d, struct variable *v)
{
void
dict_set_filter (struct dictionary *d, struct variable *v)
{
assert (v == NULL || dict_contains_var (d, v));
assert (v == NULL || var_is_numeric (v));
assert (v == NULL || dict_contains_var (d, v));
assert (v == NULL || var_is_numeric (v));
casenumber
dict_get_case_limit (const struct dictionary *d)
{
casenumber
dict_get_case_limit (const struct dictionary *d)
{
void
dict_set_case_limit (struct dictionary *d, casenumber case_limit)
{
void
dict_set_case_limit (struct dictionary *d, casenumber case_limit)
{
d->case_limit = case_limit;
}
d->case_limit = case_limit;
}
int
dict_get_next_value_idx (const struct dictionary *d)
{
int
dict_get_next_value_idx (const struct dictionary *d)
{
return d->next_value_idx;
}
return d->next_value_idx;
}
size_t
dict_get_case_size (const struct dictionary *d)
{
size_t
dict_get_case_size (const struct dictionary *d)
{
return sizeof (union value) * dict_get_next_value_idx (d);
}
return sizeof (union value) * dict_get_next_value_idx (d);
}
const struct variable *const *
dict_get_split_vars (const struct dictionary *d)
{
const struct variable *const *
dict_get_split_vars (const struct dictionary *d)
{
size_t
dict_get_split_cnt (const struct dictionary *d)
{
size_t
dict_get_split_cnt (const struct dictionary *d)
{
dict_set_split_vars (struct dictionary *d,
struct variable *const *split, size_t cnt)
{
dict_set_split_vars (struct dictionary *d,
struct variable *const *split, size_t cnt)
{
assert (cnt == 0 || split != NULL);
d->split_cnt = cnt;
assert (cnt == 0 || split != NULL);
d->split_cnt = cnt;
const char *
dict_get_label (const struct dictionary *d)
{
const char *
dict_get_label (const struct dictionary *d)
{
void
dict_set_label (struct dictionary *d, const char *label)
{
void
dict_set_label (struct dictionary *d, const char *label)
{
free (d->label);
d->label = label != NULL ? xstrndup (label, 60) : NULL;
}
free (d->label);
d->label = label != NULL ? xstrndup (label, 60) : NULL;
}
assert (cnt > 0);
for (i = 0; i < cnt; i++)
assert (dict_contains_var (d, var[i]));
assert (cnt > 0);
for (i = 0; i < cnt; i++)
assert (dict_contains_var (d, var[i]));
const struct vector *
dict_get_vector (const struct dictionary *d, size_t idx)
{
const struct vector *
dict_get_vector (const struct dictionary *d, size_t idx)
{
assert (idx < d->vector_cnt);
return d->vector[idx];
assert (idx < d->vector_cnt);
return d->vector[idx];
size_t
dict_get_vector_cnt (const struct dictionary *d)
{
size_t
dict_get_vector_cnt (const struct dictionary *d)
{