Exemple #1
0
/* Remove elems of V that are covered by another elem. V must be a diff list.
   LEN is length of each array. */
static void
vec_compact (struct hs_vec *v, int len)
{
  for (int i = 0; i < v->used; i++) {
    for (int j = i + 1; j < v->used; j++) {
      int sub;
      if (array_is_sub (v->elems[i], v->elems[j], len)) sub = j;
      else if (array_is_sub (v->elems[j], v->elems[i], len)) sub = i;
      else continue;

      vec_elem_free (v, sub);
      if (sub == j) { j--; continue; }
      else { i--; break; }
    }
  }
}
Exemple #2
0
Fichier : hs.c Projet : NetSys/sts
bool
hs_compact_m (struct hs *hs, const array_t *mask)
{
  struct hs_vec *v = &hs->list;
  for (int i = 0; i < v->used; i++) {
    vec_compact (&v->diff[i], mask, hs->len);
    for (int j = 0; j < v->diff[i].used; j++) {
      if (!array_is_sub (v->diff[i].elems[j], v->elems[i], hs->len)) continue;
      vec_elem_free (v, i);
      i--; break;
    }
  }
  return v->used;
}