src/misc/espresso/contain.c File Reference
#include "espresso.h"
Go to the source code of this file.
Functions |
pset_family | sf_contain (INOUT pset_family A) |
pset_family | sf_rev_contain (INOUT pset_family A) |
pset_family | sf_ind_contain (INOUT pset_family A, INOUT int *row_indices) |
pset_family | sf_dupl (INOUT pset_family A) |
pset_family | sf_union (INOUT pset_family A, INOUT pset_family B) |
pset_family | dist_merge (INOUT pset_family A, IN pset mask) |
pset_family | d1merge (INOUT pset_family A, IN int var) |
int | d1_rm_equal (pset *A1, int(*compare)()) |
int | rm_equal (INOUT pset *A1, IN int(*compare)()) |
int | rm_contain (INOUT pset *A1) |
int | rm_rev_contain (INOUT pset *A1) |
int | rm2_equal (INOUT register pset *A1, INOUT register pset *B1, OUT pset *E1, IN int(*compare)()) |
int | rm2_contain (INOUT pset *A1, IN pset *B1) |
pset * | sf_sort (IN pset_family A, IN int(*compare)()) |
pset * | sf_list (IN register pset_family A) |
pset_family | sf_unlist (IN pset *A1, IN int totcnt, IN int size) |
pset_family | sf_ind_unlist (IN pset *A1, IN int totcnt, IN int size, INOUT int *row_indices, IN register pset pfirst) |
pset_family | sf_merge (INOUT pset *A1, INOUT pset *B1, INOUT pset *E1, IN int totcnt, IN int size) |
Function Documentation
int d1_rm_equal |
( |
pset * |
A1, |
|
|
int (*)() |
compare | |
|
) |
| | |
Definition at line 168 of file contain.c.
00171 {
00172 register int i, j, dest;
00173
00174 dest = 0;
00175 if (A1[0] != (pcube) NULL) {
00176 for(i = 0, j = 1; A1[j] != (pcube) NULL; j++)
00177 if ( (*compare)(&A1[i], &A1[j]) == 0) {
00178
00179 (void) set_or(A1[i], A1[i], A1[j]);
00180 } else {
00181
00182 A1[dest++] = A1[i];
00183 i = j;
00184 }
00185 A1[dest++] = A1[i];
00186 }
00187 A1[dest] = (pcube) NULL;
00188 return dest;
00189 }
int rm2_contain |
( |
INOUT pset * |
A1, |
|
|
IN pset * |
B1 | |
|
) |
| | |
Definition at line 297 of file contain.c.
00300 {
00301 register pset *pa, *pb, a, b, *pdest = A1;
00302
00303
00304 for(pa = A1; (a = *pa++) != NULL; ) {
00305
00306 for(pb = B1; (b = *pb++) != NULL && SIZE(b) > SIZE(a); ) {
00307 INLINEsetp_implies(a, b, continue);
00308
00309 goto lnext1;
00310 }
00311
00312 *pdest++ = a;
00313 lnext1: ;
00314 }
00315
00316 *pdest = NULL;
00317 return pdest - A1;
00318 }
int rm2_equal |
( |
INOUT register pset * |
A1, |
|
|
INOUT register pset * |
B1, |
|
|
OUT pset * |
E1, |
|
|
IN int (*)() |
compare | |
|
) |
| | |
Definition at line 267 of file contain.c.
00271 {
00272 register pset *pda = A1, *pdb = B1, *pde = E1;
00273
00274
00275 for(; *A1 != NULL && *B1 != NULL; )
00276 switch((*compare)(A1, B1)) {
00277 case -1:
00278 *pda++ = *A1++; break;
00279 case 0:
00280 *pde++ = *A1++; B1++; break;
00281 case 1:
00282 *pdb++ = *B1++; break;
00283 }
00284
00285
00286 while (*A1 != NULL)
00287 *pda++ = *A1++;
00288 while (*B1 != NULL)
00289 *pdb++ = *B1++;
00290 *pda = *pdb = *pde = NULL;
00291
00292 return pde - E1;
00293 }
int rm_contain |
( |
INOUT pset * |
A1 |
) |
|
Definition at line 211 of file contain.c.
00213 {
00214 register pset *pa, *pb, *pcheck, a, b;
00215 pset *pdest = A1;
00216 int last_size = -1;
00217
00218
00219 for(pa = A1; (a = *pa++) != NULL; ) {
00220
00221 if (SIZE(a) != last_size)
00222 last_size = SIZE(a), pcheck = pdest;
00223 for(pb = A1; pb != pcheck; ) {
00224 b = *pb++;
00225 INLINEsetp_implies(a, b, continue);
00226 goto lnext1;
00227 }
00228
00229 *pdest++ = a;
00230 lnext1: ;
00231 }
00232
00233 *pdest = NULL;
00234 return pdest - A1;
00235 }
int rm_equal |
( |
INOUT pset * |
A1, |
|
|
IN int (*)() |
compare | |
|
) |
| | |
Definition at line 193 of file contain.c.
00196 {
00197 register pset *p, *pdest = A1;
00198
00199 if (*A1 != NULL) {
00200 for(p = A1+1; *p != NULL; p++)
00201 if ((*compare)(p, p-1) != 0)
00202 *pdest++ = *(p-1);
00203 *pdest++ = *(p-1);
00204 *pdest = NULL;
00205 }
00206 return pdest - A1;
00207 }
int rm_rev_contain |
( |
INOUT pset * |
A1 |
) |
|
Definition at line 239 of file contain.c.
00241 {
00242 register pset *pa, *pb, *pcheck, a, b;
00243 pset *pdest = A1;
00244 int last_size = -1;
00245
00246
00247 for(pa = A1; (a = *pa++) != NULL; ) {
00248
00249 if (SIZE(a) != last_size)
00250 last_size = SIZE(a), pcheck = pdest;
00251 for(pb = A1; pb != pcheck; ) {
00252 b = *pb++;
00253 INLINEsetp_implies(b, a, continue);
00254 goto lnext1;
00255 }
00256
00257 *pdest++ = a;
00258 lnext1: ;
00259 }
00260
00261 *pdest = NULL;
00262 return pdest - A1;
00263 }
pset_family sf_ind_unlist |
( |
IN pset * |
A1, |
|
|
IN int |
totcnt, |
|
|
IN int |
size, |
|
|
INOUT int * |
row_indices, |
|
|
IN register pset |
pfirst | |
|
) |
| | |
Definition at line 375 of file contain.c.
00380 {
00381 register pset pr, p, *pa;
00382 register int i, *new_row_indices;
00383 pset_family R = sf_new(totcnt, size);
00384
00385 R->count = totcnt;
00386 new_row_indices = ALLOC(int, totcnt);
00387 for(pr = R->data, pa = A1, i=0; (p = *pa++) != NULL; pr += R->wsize, i++) {
00388 INLINEset_copy(pr, p);
00389 new_row_indices[i] = row_indices[(p - pfirst)/R->wsize];
00390 }
00391 for(i = 0; i < totcnt; i++)
00392 row_indices[i] = new_row_indices[i];
00393 FREE(new_row_indices);
00394 FREE(A1);
00395 return R;
00396 }
Definition at line 344 of file contain.c.
00346 {
00347 register pset p, last, *pdest, *A1;
00348
00349
00350 pdest = A1 = ALLOC(pset, A->count + 1);
00351 foreach_set(A, last, p)
00352 *pdest++ = p;
00353 *pdest = NULL;
00354 return A1;
00355 }
Definition at line 400 of file contain.c.
00403 {
00404 register pset pr, ps, *pmin, *pmid, *pmax;
00405 pset_family R;
00406 pset *temp[3], *swap;
00407 int i, j, n;
00408
00409
00410 R = sf_new(totcnt, size);
00411 R->count = totcnt;
00412 pr = R->data;
00413
00414
00415 n = 3; temp[0] = A1; temp[1] = B1; temp[2] = E1;
00416 for(i = 0; i < n-1; i++)
00417 for(j = i+1; j < n; j++)
00418 if (desc1(*temp[i], *temp[j]) > 0) {
00419 swap = temp[j];
00420 temp[j] = temp[i];
00421 temp[i] = swap;
00422 }
00423 pmin = temp[0]; pmid = temp[1]; pmax = temp[2];
00424
00425
00426 while (*pmin != (pset) NULL) {
00427 ps = *pmin++;
00428 INLINEset_copy(pr, ps);
00429 pr += R->wsize;
00430 if (desc1(*pmin, *pmax) > 0) {
00431 swap = pmax; pmax = pmin; pmin = pmid; pmid = swap;
00432 } else if (desc1(*pmin, *pmid) > 0) {
00433 swap = pmin; pmin = pmid; pmid = swap;
00434 }
00435 }
00436
00437 FREE(A1);
00438 FREE(B1);
00439 FREE(E1);
00440 return R;
00441 }
Definition at line 323 of file contain.c.
00326 {
00327 register pset p, last, *pdest, *A1;
00328
00329
00330 pdest = A1 = ALLOC(pset, A->count + 1);
00331 foreach_set(A, last, p) {
00332 PUTSIZE(p, set_ord(p));
00333 *pdest++ = p;
00334 }
00335 *pdest = NULL;
00336
00337
00338 qsort((char *) A1, A->count, sizeof(pset), compare);
00339 return A1;
00340 }
Definition at line 118 of file contain.c.
00120 {
00121 int cnt;
00122 pset_family R;
00123 pset *A1 = sf_list(A), *B1 = sf_list(B), *E1;
00124
00125 E1 = ALLOC(pset, MAX(A->count, B->count) + 1);
00126 cnt = rm2_equal(A1, B1, E1, descend);
00127 cnt += rm2_contain(A1, B1) + rm2_contain(B1, A1);
00128 R = sf_merge(A1, B1, E1, cnt, A->sf_size);
00129 sf_free(A); sf_free(B);
00130 return R;
00131 }