[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: var_create_internal
From: |
John Darrington |
Subject: |
Re: var_create_internal |
Date: |
Thu, 8 Jan 2009 08:31:40 +0900 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On Wed, Jan 07, 2009 at 05:17:40PM -0500, Jason Stover wrote:
Question:
/* Create a variable to be used for internal calculations only */
struct variable *
var_create_internal (int case_idx)
{
struct variable *v = var_create ("$internal", 0);
struct vardict_info vdi;
vdi.dict = NULL;
vdi.dict_index = 0;
vdi.case_index = case_idx;
var_set_vardict (v, &vdi);
return v;
}
/* Dictionary data stored in variable. */
struct vardict_info
{
int dict_index; /* Dictionary index containing the variable. */
int case_index; /* Index into case of variable data. */
struct dictionary *dict; /* The dictionary containing the variable */
};
What is the "case of variable data"?
It's the index which needs to be passed to case_data_idx in order to
access the value of this variable.
All the examples I see in
src/language/stats show a value of either 0, 1 or 2.
"Internal" variables are a convenience object, typically used when
calculations require, or benefit from, a temporary casereader.
Copying, and iterating a casereader with a small number of variables
is cheaper than copying and iterating the input data, which can,
potentially have a very large number of variables. That's why these
indices are small.
J'
--
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.
signature.asc
Description: Digital signature