Exemplo n.º 1
0
static void sim_clear_events(struct simulator *sim) {
  int i;
  for (i = 0; i < sim->num_signals; i++) {
    sim->signals[i].event = 0;
  }
  sim->any_event = 0;
  bv_clear(&sim->events);
}
Exemplo n.º 2
0
/*
 *  call-seq:
 *     bv.clear -> self
 *  
 *  Clears all set bits in the bit-vector. Negated bit-vectors will still have
 *  all bits set to *off*.
 */
VALUE
frt_bv_clear(VALUE self)
{
    BitVector *bv;
    GET_BV(bv, self);
    bv_clear(bv);
    bv_scan_reset(bv);
    return self;
}
Exemplo n.º 3
0
/* i_igremove: remove node i from IG g */
static inline void i_igremove (i_local_t i, ig_t g) {
     rmn = i;			/* Remove i from each of its neighbors */
     bv_eachbit(row(i, g), i_igrmnode, (void *)g);
     bv_clear(row(i, g));	/* Clear row i */
     removed[i] = 1;
}
Exemplo n.º 4
0
/**
 * Stress test BitVector Scanning as well as bv_set_fast. This test has been
 * run successfully with BV_DENSE_SCAN_SIZE set to 20000000 and BV_SCAN_INC
 * set to 97. When running this test with high numbers, be sure use -q on the
 * command line or the test will take a very long time.
 */
static void test_bv_scan_stress(TestCase *tc, void *data)
{
    int i;
    BitVector *bv = bv_new_capa(BV_SCAN_SIZE);
    BitVector *not_bv;
    (void)data; /* suppress unused argument warning */

    for (i = BV_SCAN_INC; i < BV_SCAN_SIZE; i += BV_SCAN_INC) {
        bv_set_fast(bv, i);
        Aiequal(bv_get(bv, i), 1);
        Aiequal(bv_get(bv, i-1), 0);
        Aiequal(bv_get(bv, i+1), 0);
    }

    not_bv = bv_not(bv);

    for (i = BV_SCAN_INC; i < BV_SCAN_SIZE; i += BV_SCAN_INC) {
        Aiequal(i, bv_scan_next_from(bv, i - BV_SCAN_INC / 2));
        Aiequal(i, bv_scan_next_unset_from(not_bv, i - BV_SCAN_INC / 2));
    }
    Aiequal(-1, bv_scan_next_from(bv, i - BV_SCAN_INC / 2));
    Aiequal(-1, bv_scan_next_unset_from(not_bv, i - BV_SCAN_INC / 2));

    /* test scan_next_from where size is actually greater than the highest set
     * bit */
    bv_unset(bv, bv->size);
    bv_set(not_bv, not_bv->size);

    bv_scan_reset(bv);
    bv_scan_reset(not_bv);
    for (i = BV_SCAN_INC; i < BV_SCAN_SIZE; i += BV_SCAN_INC) {
        Aiequal(i, bv_scan_next_from(bv, i - BV_SCAN_INC / 2));
        Aiequal(i, bv_scan_next_unset_from(not_bv, i - BV_SCAN_INC / 2));
    }
    Aiequal(-1, bv_scan_next_from(bv, i - BV_SCAN_INC / 2));
    Aiequal(-1, bv_scan_next_unset_from(not_bv, i - BV_SCAN_INC / 2));

    bv_scan_reset(bv);
    bv_scan_reset(not_bv);
    for (i = BV_SCAN_INC; i < BV_SCAN_SIZE; i += BV_SCAN_INC) {
        Aiequal(i, bv_scan_next(bv));
        Aiequal(i, bv_scan_next_unset(not_bv));
    }
    Aiequal(-1, bv_scan_next(bv));
    Aiequal(-1, bv_scan_next_unset(not_bv));

    bv_clear(bv);
    bv_destroy(not_bv);
    for (i = 0; i < BV_DENSE_SCAN_SIZE; i++) {
        bv_set(bv, i);
    }
    not_bv = bv_not(bv);

    for (i = 0; i < BV_DENSE_SCAN_SIZE; i++) {
        Aiequal(i, bv_scan_next_from(bv, i));
        Aiequal(i, bv_scan_next_unset_from(not_bv, i));
    }
    Aiequal(-1, bv_scan_next_from(bv, i));
    Aiequal(-1, bv_scan_next_unset_from(not_bv, i));

    bv_scan_reset(bv);
    bv_scan_reset(not_bv);
    for (i = 0; i < BV_DENSE_SCAN_SIZE; i++) {
        Aiequal(i, bv_scan_next(bv));
        Aiequal(i, bv_scan_next_unset(not_bv));
    }
    Aiequal(-1, bv_scan_next(bv));
    Aiequal(-1, bv_scan_next_unset(not_bv));

    bv_destroy(bv);
    bv_destroy(not_bv);
}
Exemplo n.º 5
0
/**
 * Test basic BitVector get/set/unset operations
 */
static void test_bv(TestCase *tc, void *data)
{
    int i;
    BitVector *bv = bv_new();
    (void)data; /* suppress unused argument warning */

    Aiequal(0, bv->size);
    Aiequal(0, bv->count);
    Aiequal(0, bv_recount(bv));

    bv_set(bv, 10);
    Aiequal(1, bv_get(bv, 10));
    Aiequal(11, bv->size);
    Aiequal(1, bv->count);
    Aiequal(1, bv_recount(bv));

    bv_set(bv, 10);
    Aiequal(1, bv_get(bv, 10));
    Aiequal(11, bv->size);
    Aiequal(1, bv->count);
    Aiequal(1, bv_recount(bv));

    bv_set(bv, 20);
    Aiequal(1, bv_get(bv, 20));
    Aiequal(21, bv->size);
    Aiequal(2, bv->count);
    Aiequal(2, bv_recount(bv));

    bv_unset(bv, 21);
    Aiequal(0, bv_get(bv, 21));
    Aiequal(22, bv->size);
    Aiequal(2, bv->count);
    Aiequal(2, bv_recount(bv));

    bv_unset(bv, 20);
    Aiequal(0, bv_get(bv, 20));
    Aiequal(22, bv->size);
    Aiequal(1, bv->count);
    Aiequal(1, bv_recount(bv));
    Aiequal(1, bv_get(bv, 10));

    bv_set(bv, 100);
    Aiequal(1, bv_get(bv, 100));
    Aiequal(101, bv->size);
    Aiequal(2, bv->count);
    Aiequal(2, bv_recount(bv));
    Aiequal(1, bv_get(bv, 10));

    bv_clear(bv);
    Aiequal(0, bv_get(bv, 10));
    Aiequal(0, bv->size);
    Aiequal(0, bv->count);
    Aiequal(0, bv_recount(bv));
    bv_unset(bv, 20);
    Aiequal(21, bv->size);

    /* test setting bits at intervals for a large number of bits */
    bv_clear(bv);
    for (i = BV_INT; i < BV_SIZE; i += BV_INT) {
        bv_set(bv, i);
    }
    for (i = BV_INT; i < BV_SIZE; i += BV_INT) {
        Aiequal(1, bv_get(bv, i));
        Aiequal(0, bv_get(bv, i - 1));
        Aiequal(0, bv_get(bv, i + 1));
    }

    /* test setting all bits */
    bv_clear(bv);
    for (i = 0; i < BV_SIZE; i++) {
        bv_set(bv, i);
    }
    for (i = 0; i < BV_SIZE; i++) {
        Aiequal(1, bv_get(bv, i));
    }

    /* test random bits */
    bv_clear(bv);
    for (i = 0; i < BV_SIZE; i++) {
        if ((rand() % 2) == 0) {
            bv_set(bv, i);
            Aiequal(1, bv_get(bv, i));
        }
    }

    bv_destroy(bv);
}
Exemplo n.º 6
0
void ctw_clear(ContextTree *tree) {
  bv_clear(tree->history);
  ctw_node_free(tree->root);
  tree->root = ctw_node_create();
  ctw_list_clear(tree->context);
}