Beispiel #1
0
/**
 * Assign hash_multimap container.
 */
void hash_multimap_assign(hash_multimap_t* phmmap_dest, const hash_multimap_t* cphmmap_src)
{
    assert(phmmap_dest != NULL);
    assert(cphmmap_src != NULL);
    assert(_pair_is_inited(&phmmap_dest->_pair_temp));
    assert(_pair_is_inited(&cphmmap_src->_pair_temp));
    assert(_hash_multimap_same_pair_type_ex(&phmmap_dest->_pair_temp, &cphmmap_src->_pair_temp));

    hash_multimap_clear(phmmap_dest);
    if (!hash_multimap_empty(cphmmap_src)) {
        hash_multimap_insert_range(phmmap_dest, hash_multimap_begin(cphmmap_src), hash_multimap_end(cphmmap_src));
    }
}
Beispiel #2
0
/**
 * Initialize hash_multimap container with hash_multimap.
 */
void hash_multimap_init_copy(hash_multimap_t* phmmap_dest, const hash_multimap_t* cphmmap_src)
{
    assert(phmmap_dest != NULL);
    assert(cphmmap_src != NULL);
    assert(_pair_is_created(&phmmap_dest->_pair_temp));
    assert(_pair_is_inited(&cphmmap_src->_pair_temp));

    hash_multimap_init_ex(phmmap_dest, hash_multimap_bucket_count(cphmmap_src), hash_multimap_hash(cphmmap_src), hash_multimap_key_comp(cphmmap_src));
    phmmap_dest->_bfun_keycompare = cphmmap_src->_bfun_keycompare;
    phmmap_dest->_bfun_valuecompare = cphmmap_src->_bfun_valuecompare;
    phmmap_dest->_pair_temp._bfun_mapkeycompare = cphmmap_src->_pair_temp._bfun_mapkeycompare;
    phmmap_dest->_pair_temp._bfun_mapvaluecompare = cphmmap_src->_pair_temp._bfun_mapvaluecompare;
    assert(_hash_multimap_same_pair_type_ex(&phmmap_dest->_pair_temp, &cphmmap_src->_pair_temp));

    if (!hash_multimap_empty(cphmmap_src)) {
        hash_multimap_insert_range(phmmap_dest, hash_multimap_begin(cphmmap_src), hash_multimap_end(cphmmap_src));
    }
}
/**
 * Initialize hash_multimap container with specific range and compare function.
 */
void hash_multimap_init_copy_range_ex(
    hash_multimap_t* phmmap_dest, hash_multimap_iterator_t it_begin, hash_multimap_iterator_t it_end,
    size_t t_bucketcount, unary_function_t ufun_hash, binary_function_t bfun_compare)
{
    unary_function_t ufun_default_hash = NULL;

    assert(phmmap_dest != NULL);
    assert(_GET_HASH_MULTIMAP_CONTAINER_TYPE(it_begin) == _HASH_MULTIMAP_CONTAINER);
    assert(_GET_HASH_MULTIMAP_ITERATOR_TYPE(it_begin) == _BIDIRECTIONAL_ITERATOR);
    assert(_GET_HASH_MULTIMAP_CONTAINER_TYPE(it_end) == _HASH_MULTIMAP_CONTAINER);
    assert(_GET_HASH_MULTIMAP_ITERATOR_TYPE(it_end) == _BIDIRECTIONAL_ITERATOR);
    assert(_GET_HASH_MULTIMAP_CONTAINER(it_begin) != phmmap_dest);
    assert(_GET_HASH_MULTIMAP_CONTAINER(it_end) != phmmap_dest);
    assert(_GET_HASH_MULTIMAP_CONTAINER(it_begin) == _GET_HASH_MULTIMAP_CONTAINER(it_end));
    assert(_hash_multimap_same_pair_type(&phmmap_dest->_pair_temp, &_GET_HASH_MULTIMAP_CONTAINER(it_begin)->_pair_temp));

    ufun_default_hash = ufun_hash != NULL ? ufun_hash : _hash_multimap_default_hash;
    hash_multimap_init_ex(phmmap_dest, t_bucketcount, ufun_default_hash, bfun_compare);
    if(!hash_multimap_empty(_GET_HASH_MULTIMAP_CONTAINER(it_begin)))
    {
        hash_multimap_insert_range(phmmap_dest, it_begin, it_end);
    }
}