Chapter 6.  Db_multimap

This class is the combination of std::multimap and hash_multimap.

By setting database handles as DB_BTREE or DB_HASH type respectively, you will be using an equivalent of std::multimap or hash_multimap respectively. Database(dbp) and environment(penv) handle requirement: The dbp handle must meet the following requirement: 1. Database type should be DB_BTREE or DB_HASH. 2. Either DB_DUP or DB_DUPSORT flag must be set. Note that so far Berkeley DB does not allow DB_DUPSORT be set and the database is storing identical key/data pairs, i.e. we can't store two (1, 2), (1, 2) pairs into a database D with DB_DUPSORT flag set, but only can do so with DB_DUP flag set; But we can store a (1, 2) pair and a (1, 3) pair into D with DB_DUPSORT flag set. So if your data set allows DB_DUPSORT flag, you should set it to gain a lot of performance promotion. 3. No DB_RECNUM flag set. 4. No DB_TRUNCATE specified in database open flags. 5. DB_THREAD must be set if you are sharing the database handle across multiple threads directly, or indirectly by sharing the container object across multiple threads.

See Also

db_container db_map

Class Template Parameters

kdt

The key data type.

ddt

The data data type. db_multimap stores key/data pairs.

value_type_sub

Do not specify anything if ddt type is a class/struct type; Otherwise, specify ElementHolder<ddt> to it.

iterator_t

Never specify anything to this type parameter. It is only used internally.

Public Members

Member Description
insert

Range insertion.

erase

Erase elements by key.

equal_range

Find the range within which all keys equal to specified key x.

equal_range_N

Find equal range and number of key/data pairs in the range.

count

Count the number of key/data pairs having specified key x.

upper_bound

Find the least key greater than x.

db_multimap

Constructor.

~db_multimap
operator=

Container content assignment operator.

swap

Swap content with another multimap container.

operator==

Returns whether the two containers have identical content.

operator!=

Container unequality comparison operator.

Group

Dbstl Container Classes

insert

Function Details

void insert(InputIterator first,
    InputIterator last)
 

Range insertion.

Insert a range [first, last) of key/data pairs into this container.

Parameters

last

The open boundary of the range.

first

The closed boundary of the range.

void insert(const_iterator &first,
    const_iterator &last)
 

Range insertion.

Insert a range [first, last) of key/data pairs into this container.

Parameters

last

The open boundary of the range.

first

The closed boundary of the range.

iterator insert(const value_type &x)
 

Insert a single key/data pair if the key is not in the container.

Parameters

x

The key/data pair to insert.

Return Value

A pair P, if insert OK, i.e. the inserted key wasn't in the container, P.first will be the iterator sitting on the inserted key/data pair, and P.second is true; otherwise P.first is an invalid iterator and P.second is false.

Class

db_multimap