13 static unsigned int fnv_hash(
void *key,
int len);
27 int *tuple = (
int*)malloc((len+1)*
sizeof(int));
32 for (i = 0; i < len; i++)
33 tuple[i] = va_arg(ap,
int);
50 while (*p++ != INT_MAX);
69 va_start(ap, first_tuple);
71 while ((tuple = va_arg(ap,
int*)) != NULL)
75 int *out_tuple = (
int*)malloc((len+1)*
sizeof(int));
76 prt_assert(out_tuple != NULL,
"malloc failed");
77 va_start(ap, first_tuple);
78 while(*first_tuple != INT_MAX)
79 *out_tuple++ = *first_tuple++;
80 while ((tuple = va_arg(ap,
int*)) != NULL)
81 while(*tuple != INT_MAX)
82 *out_tuple++ = *tuple++;
86 return (out_tuple-len);
114 while (in_tuple[len] != INT_MAX)
116 out_tuple = (
int*)malloc((len+1)*
sizeof(int));
117 prt_assert(out_tuple != NULL,
"malloc failed");
118 for (i = 0; i < len; i++)
119 out_tuple[i] = in_tuple[i];
120 out_tuple[len] = INT_MAX;
137 int *tupa = (
int*)tuple_a;
138 int *tupb = (
int*)tuple_b;
139 while (*tupa != INT_MAX && *tupb != INT_MAX) {
140 if (*tupa < *tupb)
return -1;
141 else if (*tupa > *tupb)
return 1;
145 if (*tupa == INT_MAX && *tupb == INT_MAX)
return 0;
146 else if (*tupa == INT_MAX)
return -1;
147 else if (*tupb == INT_MAX)
return 1;
174 while (*tuple != INT_MAX)
175 printf(
"%3d", *tuple++);
191 int *tup = (
int*)tuple;
192 while (tup[len] != INT_MAX)
194 return fnv_hash(tuple, len*
sizeof(
int));
207 static unsigned int fnv_hash(
void *key,
int len)
209 unsigned char *p = key;
210 unsigned h = 2166136261;
212 for (i = 0; i < len; i++)
213 h = (h * 16777619) ^ p[i];
void prt_tuple_print(int *tuple)
tuple print
int * prt_tuple_cat(int *first_tuple,...)
tuple concatenate Join a variable length, NULL-terminated, list of tuples.
int prt_tuple_compare(void *tuple_a, void *tuple_b)
tuple comparison
unsigned int prt_tuple_hash(void *tuple)
tuple hash Required by the VSA's tuples hash table. Computes the lenght in characters and calls a str...
int prt_tuple_len(int *tuple)
tuple length
int * prt_tuple_copy(int *in_tuple)
tuple copy constructor
void prt_tuple_delete(int *tuple)
tuple destructor
int * prt_tuple_new(int len,...)
tuple constructor Allocates memory for the tuple plus the termination symbol (INT_MAX).
#define prt_assert(cond, msg)
int prt_tuple_equal(void *tuple_a, void *tuple_b)
tuple equality check Check if tuples are identical in length and content.