Example #1
0
/**
 * Initialize hashtable container with specific array.
 */
void _hashtable_init_copy_unique_array(
    _hashtable_t* pt_dest, const void* cpv_array, size_t t_count, size_t t_bucketcount,
    ufun_t ufun_hash, bfun_t bfun_compare)
{
    assert(pt_dest != NULL);
    assert(_hashtable_is_created(pt_dest));
    assert(cpv_array != NULL);

    _hashtable_init(pt_dest, t_bucketcount, ufun_hash, bfun_compare);
    _hashtable_insert_unique_array(pt_dest, cpv_array, t_count);
}
Example #2
0
/**
 * Initialize hashtable container with specific range.
 */
void _hashtable_init_copy_unique_range(
    _hashtable_t* pt_dest, iterator_t it_begin, iterator_t it_end, size_t t_bucketcount,
    ufun_t ufun_hash, bfun_t bfun_compare)
{
    assert(pt_dest != NULL);
    assert(_hashtable_is_created(pt_dest));
    assert(_hashtable_same_iterator_type(pt_dest, it_begin));
    assert(_hashtable_same_iterator_type(pt_dest, it_end));
    assert(iterator_equal(it_begin, it_end) || _iterator_before(it_begin, it_end));

    _hashtable_init(pt_dest, t_bucketcount, ufun_hash, bfun_compare);
    _hashtable_insert_unique_range(pt_dest, it_begin, it_end);
}
Example #3
0
/**
 * Initialize hash_multimap container with user define compare function.
 */
void hash_multimap_init_ex(hash_multimap_t* phmmap_map, size_t t_bucketcount, unary_function_t ufun_hash, binary_function_t bfun_compare)
{
    unary_function_t ufun_default_hash = NULL;

    assert(phmmap_map != NULL);
    assert(_pair_is_created(&phmmap_map->_pair_temp));

    /* initialize the pair */
    pair_init(&phmmap_map->_pair_temp);
    phmmap_map->_bfun_keycompare = bfun_compare;
    phmmap_map->_pair_temp._bfun_mapkeycompare = bfun_compare;
    ufun_default_hash = ufun_hash != NULL ? ufun_hash : _hash_multimap_default_hash;

    /* initialize the hashtable */
    _hashtable_init(&phmmap_map->_t_hashtable, t_bucketcount, ufun_default_hash, _hash_multimap_value_compare);
}
Example #4
0
/**
 * Initialize hashtable container with hashtable.
 */
void _hashtable_init_copy(_hashtable_t* pt_dest, const _hashtable_t* cpt_src)
{
    assert(pt_dest != NULL);
    assert(cpt_src != NULL);
    assert(_hashtable_is_created(pt_dest));
    assert(_hashtable_is_inited(cpt_src));
    assert(_hashtable_same_type(pt_dest, cpt_src));

    /* initialize the dest hashtable with src hashtable attribute */
    _hashtable_init(pt_dest, _hashtable_bucket_count(cpt_src), cpt_src->_ufun_hash, cpt_src->_bfun_compare);
    /* insert node from src to dest */
    if(!_hashtable_empty(cpt_src))
    {
        _hashtable_insert_equal_range(pt_dest, _hashtable_begin(cpt_src), _hashtable_end(cpt_src));
    }
}
Example #5
0
/**
 * Initialize hashtable container with specific range.
 */
void _hashtable_init_copy_range(
    _hashtable_t* pt_dest, _hashtable_iterator_t it_begin, _hashtable_iterator_t it_end,
    size_t t_bucketcount, unary_function_t ufun_hash, binary_function_t bfun_compare)
{
    assert(pt_dest != NULL);
    assert(_hashtable_is_created(pt_dest));
    assert(_hashtable_same_hashtable_iterator_type(pt_dest, it_begin));
    assert(_hashtable_same_hashtable_iterator_type(pt_dest, it_end));
    assert(_hashtable_iterator_equal(it_begin, it_end) || _hashtable_iterator_before(it_begin, it_end));

    /* initialize the dest hashtable with src hashtable attribute */
    _hashtable_init(pt_dest, t_bucketcount, ufun_hash, bfun_compare);
    /* insert node from src to dest */
    if(!_hashtable_empty(_GET_HASHTABLE(it_begin)))
    {
        _hashtable_insert_equal_range(pt_dest, it_begin, it_end);
    }
}
Example #6
0
/**
 * Initialize hashtable container with hashtable.
 */
void _hashtable_init_copy(_hashtable_t* pt_dest, const _hashtable_t* cpt_src)
{
    _hashtable_iterator_t it_iter;

    assert(pt_dest != NULL);
    assert(cpt_src != NULL);
    assert(_hashtable_is_created(pt_dest));
    assert(_hashtable_is_inited(cpt_src));
    assert(_hashtable_same_type(pt_dest, cpt_src));

    /* initialize the dest hashtable with src hashtable attribute */
    _hashtable_init(pt_dest, _hashtable_bucket_count(cpt_src), cpt_src->_ufun_hash, cpt_src->_bfun_compare);
    /* insert node from src to dest */
    for (it_iter = _hashtable_begin(cpt_src);
         !_hashtable_iterator_equal(it_iter, _hashtable_end(cpt_src));
         it_iter = _hashtable_iterator_next(it_iter)) {
        _hashtable_insert_equal(pt_dest, _hashtable_iterator_get_pointer_ignore_cstr(it_iter));
    }
}
Example #7
0
/**
 * Initialize hash_set container with user define compare function.
 */
void hash_set_init_ex(hash_set_t* phset_set, size_t t_bucketcount, unary_function_t ufun_hash, binary_function_t bfun_compare)
{
    assert(phset_set != NULL);

    _hashtable_init(&phset_set->_t_hashtable, t_bucketcount, ufun_hash, bfun_compare);
}