Beispiel #1
0
void types_visitor::print_complex_item(complex_item* item)
{
    switch(item->type)
    {
    case COMPLEX_SIMPLE: print_simple_item(item->data._simple); break;
    case COMPLEX_TUPLE:  print_tuple(item->data._tuple); break;
    case COMPLEX_BAG:    print_bag(item->data._bag); break;
    case COMPLEX_MAP:    print_map(item->data._map); break;
    }
}
Beispiel #2
0
/*
 * Test add and remove
 */
int main(void) {
  uint32_t i;
  int32_t k;

  for (i=0; i<NUMTESTS; i ++) {
    index[i] = -1;
  }

  bag = NULL;
  printf("*** Initial bag ***\n");
  print_bag(bag);


  for (i=0; i<NUMTESTS; i += 2) {
    k = ibag_add(&bag, data[i]);
    index[i] = k;
    printf("Adding %"PRId32": index = %"PRId32"\n", data[i], k);
  }
  print_bag(bag);
  printf("\n");

  for (i=0; i<NUMTESTS; i += 4) {
    k = index[i];
    if (k >= 0) {
      printf("Removing %"PRId32" at index %"PRId32"\n", data[i], k);
      ibag_clear_elem(bag, k);
      index[i] = -1;
    }
  }
  print_bag(bag);
  printf("\n");

  for (i=0; i<NUMTESTS; i++) {
    k = index[i];
    if (k < 0) {
      k = ibag_add(&bag, data[i]);
      index[i] = k;
      printf("Adding %"PRId32": index = %"PRId32"\n", data[i], k);
      print_bag(bag);
    }
  }

  for (i=20; i<NUMTESTS; i += 3) {
    k = index[i];
    if (k >= 0) {
      printf("Removing %"PRId32" at index %"PRId32"\n", data[i], k);
      ibag_clear_elem(bag, k);
      print_bag(bag);
      index[i] = -1;
    }
  }

  printf("**** Reset ****\n");
  ibag_reset(bag);
  print_bag(bag);

  ibag_delete(bag);
  return 0;
}