From: John Darrington Date: Wed, 6 Jul 2011 15:54:32 +0000 (+0200) Subject: Change interaction functions to use cases rather than value arrays X-Git-Tag: v0.7.9~203 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a82e941418b74d8f270cf164291a3938fff61d5;p=pspp-builds.git Change interaction functions to use cases rather than value arrays --- diff --git a/src/math/interaction.c b/src/math/interaction.c index c06acde8..aa242500 100644 --- a/src/math/interaction.c +++ b/src/math/interaction.c @@ -16,6 +16,7 @@ #include +#include "data/case.h" #include "interaction.h" #include "data/value.h" @@ -97,27 +98,29 @@ interaction_to_string (const struct interaction *iact, struct string *str) } unsigned int -interaction_value_hash (const struct interaction *iact, const union value *val) +interaction_case_hash (const struct interaction *iact, const struct ccase *c) { int i; size_t hash = 0; for (i = 0; i < iact->n_vars; ++i) { - hash = value_hash (&val[i], var_get_width (iact->vars[i]), hash); + const struct variable *var = iact->vars[i]; + const union value *val = case_data (c, var); + hash = value_hash (val, var_get_width (var), hash); } - return hash; } bool -interaction_value_equal (const struct interaction *iact, const union value *val1, const union value *val2) +interaction_case_equal (const struct interaction *iact, const struct ccase *c1, const struct ccase *c2) { int i; bool same = true; for (i = 0; i < iact->n_vars; ++i) { - if ( ! value_equal (&val1[i], &val2[i], var_get_width (iact->vars[i]))) + const struct variable *var = iact->vars[i]; + if ( ! value_equal (case_data (c1, var), case_data (c2, var), var_get_width (var))) { same = false; break; @@ -127,16 +130,15 @@ interaction_value_equal (const struct interaction *iact, const union value *val1 return same; } - bool -interaction_value_is_missing (const struct interaction *iact, const union value *val, enum mv_class exclude) +interaction_case_is_missing (const struct interaction *iact, const struct ccase *c, enum mv_class exclude) { int i; bool missing = false; for (i = 0; i < iact->n_vars; ++i) { - if ( var_is_value_missing (iact->vars[i], &val[i], exclude)) + if ( var_is_value_missing (iact->vars[i], case_data (c, iact->vars[i]), exclude)) { missing = true; break; @@ -145,3 +147,4 @@ interaction_value_is_missing (const struct interaction *iact, const union value return missing; } + diff --git a/src/math/interaction.h b/src/math/interaction.h index bffe7518..96c2940a 100644 --- a/src/math/interaction.h +++ b/src/math/interaction.h @@ -32,8 +32,6 @@ struct interaction const struct variable **vars; }; - - struct interaction * interaction_create (const struct variable *); void interaction_destroy (struct interaction *); void interaction_add_variable (struct interaction *, const struct variable *); @@ -41,10 +39,9 @@ void interaction_dump (const struct interaction *); void interaction_to_string (const struct interaction *iact, struct string *str); -union value; - -unsigned int interaction_value_hash (const struct interaction *, const union value *); -bool interaction_value_equal (const struct interaction *, const union value *, const union value *); -bool interaction_value_is_missing (const struct interaction *, const union value *, enum mv_class); +struct ccase; +unsigned int interaction_case_hash (const struct interaction *, const struct ccase *); +bool interaction_case_equal (const struct interaction *, const struct ccase *, const struct ccase *); +bool interaction_case_is_missing (const struct interaction *, const struct ccase *, enum mv_class); #endif