Exemple #1
0
static tb_size_t tb_vector_ninsert_test()
{
    // init
    tb_vector_ref_t vector = tb_vector_init(TB_VECTOR_GROW_SIZE, tb_element_long());
    tb_assert_and_check_return_val(vector, 0);

    // insert one first
    tb_vector_insert_head(vector, (tb_pointer_t)0xf);

    tb_size_t n = 10000;
    tb_hong_t t = tb_mclock();
    tb_vector_ninsert_prev(vector, 1, (tb_pointer_t)0xf, n);
    t = tb_mclock() - t;

    // time
    tb_trace_i("tb_vector_ninsert_prev(%lu): %lld ms, size: %lu, maxn: %lu", n, t, tb_vector_size(vector), tb_vector_maxn(vector));

    // check
    tb_assert(tb_vector_size(vector) == n + 1);
    tb_assert(tb_vector_head(vector) == (tb_pointer_t)0xf);
    tb_assert(tb_vector_last(vector) == (tb_pointer_t)0xf);

    // clear it
    tb_vector_clear(vector);
    tb_assert(!tb_vector_size(vector));

    // exit
    tb_vector_exit(vector);

    return n / ((tb_uint32_t)(t) + 1);
}
Exemple #2
0
tb_void_t tb_vector_ninsert_tail(tb_vector_ref_t vector, tb_cpointer_t data, tb_size_t size)
{
    tb_vector_ninsert_prev(vector, tb_vector_size(vector), data, size);
}
Exemple #3
0
tb_void_t tb_vector_ninsert_head(tb_vector_ref_t vector, tb_cpointer_t data, tb_size_t size)
{
    tb_vector_ninsert_prev(vector, 0, data, size);
}
Exemple #4
0
tb_void_t tb_vector_ninsert_next(tb_vector_ref_t vector, tb_size_t itor, tb_cpointer_t data, tb_size_t size)
{
    tb_vector_ninsert_prev(vector, tb_iterator_next(vector, itor), data, size);
}