Ejemplo n.º 1
0
/**
 * Obtain data from variable argument list, the data type and deque element data type are same.
 */
void _deque_get_varg_value_auxiliary(deque_t* pdeq_deque, va_list val_elemlist, void* pv_varg)
{
    assert(pdeq_deque != NULL);
    assert(_deque_is_inited(pdeq_deque) || _deque_is_created(pdeq_deque));

    _deque_init_elem_auxiliary(pdeq_deque, pv_varg);
    _type_get_varg_value(&pdeq_deque->_t_typeinfo, val_elemlist, pv_varg);
}
Ejemplo n.º 2
0
/**
 * Initialize an element according to the type of iterator pointed data.
 */
void* _iterator_allocate_init_elem(iterator_t it_iter)
{
    void* pv_value = NULL;

    assert(_iterator_is_valid(it_iter));
    switch (it_iter._t_containertype) {
        case _VECTOR_CONTAINER:
            pv_value = _alloc_allocate(&((vector_t*)it_iter._pt_container)->_t_allocator,
                ((vector_t*)it_iter._pt_container)->_t_typeinfo._pt_type->_t_typesize, 1);
            _vector_init_elem_auxiliary((vector_t*)it_iter._pt_container, pv_value);
            break;
        case _DEQUE_CONTAINER:
            pv_value = _alloc_allocate(&((deque_t*)it_iter._pt_container)->_t_allocator,
                ((deque_t*)it_iter._pt_container)->_t_typeinfo._pt_type->_t_typesize, 1);
            _deque_init_elem_auxiliary((deque_t*)it_iter._pt_container, pv_value);
            break;
        case _BASIC_STRING_CONTAINER:
            pv_value = _alloc_allocate(&((basic_string_t*)it_iter._pt_container)->_vec_base._t_allocator,
                ((basic_string_t*)it_iter._pt_container)->_vec_base._t_typeinfo._pt_type->_t_typesize, 1);
            _basic_string_init_elem_auxiliary((basic_string_t*)it_iter._pt_container, pv_value);
            break;
        case _LIST_CONTAINER:
            pv_value = _alloc_allocate(&((list_t*)it_iter._pt_container)->_t_allocator,
                ((list_t*)it_iter._pt_container)->_t_typeinfo._pt_type->_t_typesize, 1);
            _list_init_elem_auxiliary((list_t*)it_iter._pt_container, pv_value);
            break;
        case _SLIST_CONTAINER:
            pv_value = _alloc_allocate(&((slist_t*)it_iter._pt_container)->_t_allocator,
                ((slist_t*)it_iter._pt_container)->_t_typeinfo._pt_type->_t_typesize, 1);
            _slist_init_elem_auxiliary((slist_t*)it_iter._pt_container, pv_value);
            break;
        case _SET_CONTAINER:
            pv_value = _alloc_allocate(&((set_t*)it_iter._pt_container)->_t_tree._t_allocator,
                ((set_t*)it_iter._pt_container)->_t_tree._t_typeinfo._pt_type->_t_typesize, 1);
            _set_init_elem_auxiliary((set_t*)it_iter._pt_container, pv_value);
            break;
        case _MULTISET_CONTAINER:
            pv_value = _alloc_allocate(&((multiset_t*)it_iter._pt_container)->_t_tree._t_allocator,
                ((set_t*)it_iter._pt_container)->_t_tree._t_typeinfo._pt_type->_t_typesize, 1);
            _multiset_init_elem_auxiliary((multiset_t*)it_iter._pt_container, pv_value);
            break;
        case _MAP_CONTAINER:
            pv_value = _alloc_allocate(&((map_t*)it_iter._pt_container)->_t_tree._t_allocator,
                ((map_t*)it_iter._pt_container)->_t_tree._t_typeinfo._pt_type->_t_typesize, 1);
            _map_init_elem_auxiliary((map_t*)it_iter._pt_container, pv_value);
            break;
        case _MULTIMAP_CONTAINER:
            pv_value = _alloc_allocate(&((multimap_t*)it_iter._pt_container)->_t_tree._t_allocator,
                ((multimap_t*)it_iter._pt_container)->_t_tree._t_typeinfo._pt_type->_t_typesize, 1);
            _multimap_init_elem_auxiliary((multimap_t*)it_iter._pt_container, pv_value);
            break;
        case _HASH_SET_CONTAINER:
            pv_value = _alloc_allocate(&((hash_set_t*)it_iter._pt_container)->_t_hashtable._t_allocator,
                ((hash_set_t*)it_iter._pt_container)->_t_hashtable._t_typeinfo._pt_type->_t_typesize, 1);
            _hash_set_init_elem_auxiliary((hash_set_t*)it_iter._pt_container, pv_value);
            break;
        case _HASH_MULTISET_CONTAINER:
            pv_value = _alloc_allocate(&((hash_multiset_t*)it_iter._pt_container)->_t_hashtable._t_allocator,
                ((hash_multiset_t*)it_iter._pt_container)->_t_hashtable._t_typeinfo._pt_type->_t_typesize, 1);
            _hash_multiset_init_elem_auxiliary((hash_multiset_t*)it_iter._pt_container, pv_value);
            break;
        case _HASH_MAP_CONTAINER:
            pv_value = _alloc_allocate(&((hash_map_t*)it_iter._pt_container)->_t_hashtable._t_allocator,
                ((hash_map_t*)it_iter._pt_container)->_t_hashtable._t_typeinfo._pt_type->_t_typesize, 1);
            _hash_map_init_elem_auxiliary((hash_map_t*)it_iter._pt_container, pv_value);
            break;
        case _HASH_MULTIMAP_CONTAINER:
            pv_value = _alloc_allocate(&((hash_multimap_t*)it_iter._pt_container)->_t_hashtable._t_allocator,
                ((hash_multimap_t*)it_iter._pt_container)->_t_hashtable._t_typeinfo._pt_type->_t_typesize, 1);
            _hash_multimap_init_elem_auxiliary((hash_multimap_t*)it_iter._pt_container, pv_value);
            break;
        default:
            assert(false);
            pv_value = NULL;
            break;
    }

    return pv_value;
}