Exemple #1
0
void map_init_copy(map_t* pt_mapdest, const map_t* cpt_mapsrc)
{
    assert(pt_mapdest != NULL && cpt_mapsrc != NULL);
    assert(
        pt_mapdest->_t_pair._t_firsttypesize == 
            cpt_mapsrc->_t_pair._t_firsttypesize &&
        pt_mapdest->_t_pair._t_secondtypesize ==
            cpt_mapsrc->_t_pair._t_secondtypesize);
    assert(
        strncmp(
            pt_mapdest->_t_pair._sz_firsttypename,
            cpt_mapsrc->_t_pair._sz_firsttypename,
            _ELEM_TYPE_NAME_SIZE) == 0 &&
        strncmp(
            pt_mapdest->_t_pair._sz_secondtypename,
            cpt_mapsrc->_t_pair._sz_secondtypename,
            _ELEM_TYPE_NAME_SIZE) == 0);

    /* initialize dest map with src map attribute */
    map_init(pt_mapdest);
    /* insert all element from src to dest */
    if(!map_empty(cpt_mapsrc))
    {
        map_insert_range(pt_mapdest, map_begin(cpt_mapsrc), map_end(cpt_mapsrc));
    }
}
Exemple #2
0
void map_assign(map_t* pt_mapdest, const map_t* cpt_mapsrc)
{
    assert(pt_mapdest != NULL && cpt_mapsrc != NULL);
    assert(_same_map_pair_type(&pt_mapdest->_t_pair, &cpt_mapsrc->_t_pair));

    /* destroy dest map */
    map_destroy(pt_mapdest);
    /* initialize dest map with src map attribute */
    map_init(pt_mapdest);
    /* insert all element from src to dest */
    if(!map_empty(cpt_mapsrc))
    {
        map_insert_range(pt_mapdest, map_begin(cpt_mapsrc), map_end(cpt_mapsrc));
    }
}
Exemple #3
0
/**
 * Assign map container.
 */
void map_assign(map_t* pmap_dest, const map_t* cpmap_src)
{
    assert(pmap_dest != NULL);
    assert(cpmap_src != NULL);
    assert(_pair_is_inited(&pmap_dest->_pair_temp));
    assert(_pair_is_inited(&cpmap_src->_pair_temp));
    assert(_map_same_pair_type_ex(&pmap_dest->_pair_temp, &cpmap_src->_pair_temp));

    /* clear */
    map_clear(pmap_dest);
    /* insert all element from src to dest */
    if(!map_empty(cpmap_src))
    {
        map_insert_range(pmap_dest, map_begin(cpmap_src), map_end(cpmap_src));
    }
}
Exemple #4
0
/**
 * Initialize map container with specific range and compare function.
 */
void map_init_copy_range_ex(map_t* pmap_dest, map_iterator_t it_begin, map_iterator_t it_end, binary_function_t bfun_keycompare)
{
    assert(pmap_dest != NULL);
    assert(_pair_is_created(&pmap_dest->_pair_temp));
    assert(_GET_MAP_CONTAINER_TYPE(it_begin) == _MAP_CONTAINER);
    assert(_GET_MAP_ITERATOR_TYPE(it_begin) == _BIDIRECTIONAL_ITERATOR);
    assert(_GET_MAP_CONTAINER_TYPE(it_end) == _MAP_CONTAINER);
    assert(_GET_MAP_ITERATOR_TYPE(it_end) == _BIDIRECTIONAL_ITERATOR);
    assert(_GET_MAP_CONTAINER(it_begin) != pmap_dest);
    assert(_GET_MAP_CONTAINER(it_end) != pmap_dest);
    assert(_GET_MAP_CONTAINER(it_begin) == _GET_MAP_CONTAINER(it_end));
    assert(_map_same_pair_type(&pmap_dest->_pair_temp, &_GET_MAP_CONTAINER(it_begin)->_pair_temp));

    /* initialize dest map with src map attribute */
    map_init_ex(pmap_dest, bfun_keycompare);
    /* insert all element from src to dest */
    if(!map_empty(_GET_MAP_CONTAINER(it_begin)))
    {
        map_insert_range(pmap_dest, it_begin, it_end);
    }
}
Exemple #5
0
/**
 * Initialize map container with map.
 */
void map_init_copy(map_t* pmap_dest, const map_t* cpmap_src)
{
    assert(pmap_dest != NULL);
    assert(cpmap_src != NULL);
    assert(_pair_is_created(&pmap_dest->_pair_temp));
    assert(_pair_is_inited(&cpmap_src->_pair_temp));

    /* initialize dest map with src map attribute */
    map_init(pmap_dest);
    pmap_dest->_bfun_keycompare = cpmap_src->_bfun_keycompare;
    pmap_dest->_bfun_valuecompare = cpmap_src->_bfun_valuecompare;
    pmap_dest->_pair_temp._bfun_mapkeycompare = cpmap_src->_pair_temp._bfun_mapkeycompare;
    pmap_dest->_pair_temp._bfun_mapvaluecompare = cpmap_src->_pair_temp._bfun_mapvaluecompare;

    assert(_map_same_pair_type_ex(&pmap_dest->_pair_temp, &cpmap_src->_pair_temp));
    /* insert all element from src to dest */
    if(!map_empty(cpmap_src))
    {
        map_insert_range(pmap_dest, map_begin(cpmap_src), map_end(cpmap_src));
    }
}
Exemple #6
0
void map_init_copy_range_cmp(
    map_t* pt_mapdest, map_iterator_t t_begin, map_iterator_t t_end,
    int (*pfun_key_cmp)(const void*, const void*))
{
    assert(pt_mapdest != NULL);
    assert(
        _GET_MAP_CONTAINER_TYPE(&t_begin) == _MAP_CONTAINER &&
        _GET_MAP_ITERATOR_TYPE(&t_begin) == _BIDIRECTIONAL_ITERATOR &&
        _GET_MAP_CONTAINER_TYPE(&t_end) == _MAP_CONTAINER &&
        _GET_MAP_ITERATOR_TYPE(&t_end) == _BIDIRECTIONAL_ITERATOR);
    assert(
        _GET_MAP_CONTAINER(&t_begin) != pt_mapdest &&
        _GET_MAP_CONTAINER(&t_end) != pt_mapdest &&
        _GET_MAP_CONTAINER(&t_begin) == _GET_MAP_CONTAINER(&t_end));
    assert(
        pt_mapdest->_t_pair._t_firsttypesize == 
            _GET_MAP_CONTAINER(&t_begin)->_t_pair._t_firsttypesize &&
        pt_mapdest->_t_pair._t_secondtypesize ==
            _GET_MAP_CONTAINER(&t_begin)->_t_pair._t_secondtypesize);
    assert(
        strncmp(
            pt_mapdest->_t_pair._sz_firsttypename,
            _GET_MAP_CONTAINER(&t_begin)->_t_pair._sz_firsttypename,
            _ELEM_TYPE_NAME_SIZE) == 0 &&
        strncmp(
            pt_mapdest->_t_pair._sz_secondtypename,
            _GET_MAP_CONTAINER(&t_begin)->_t_pair._sz_secondtypename,
            _ELEM_TYPE_NAME_SIZE) == 0);

    /* initialize dest map with src map attribute */
    map_init(pt_mapdest);
    pt_mapdest->_t_pair._pfun_first_cmp = pfun_key_cmp;
    /* insert all element from src to dest */
    if(!map_empty(_GET_MAP_CONTAINER(&t_begin)))
    {
        map_insert_range(pt_mapdest, t_begin, t_end);
    }
}