C++-Referenz/ Standardbibliothek/ Container-Klassen/ multimap

Alte Seite

Die Arbeit am Buch »C++-Referenz« wurde vom Hauptautor eingestellt. Ein Lehrbuch zum Thema C++ ist unter »C++-Programmierung« zu finden. Eine sehr umfangreiche und gute Referenz gibt es unter cppreference.com.

Diese Seite beschreibt C++98, einen stark veralteten Standard. Aktuelle Referenz.

// Header: map
template <typename Key, typename T, typename Compare = less<Key>, typename Allocator = allocator<T> >
class multimap{
public:
    typedef Key                                   key_type;
    typedef T                                     mapped_type;
    typedef pair<Key const,T>                     value_type;
    typedef Compare                               key_compare;
    typedef Allocator                             allocator_type;
    typedef typename Allocator::reference         reference;
    typedef typename Allocator::const_reference   const_reference;
    typedef implementation defined                iterator;
    typedef implementation defined                const_iterator;
    typedef typename Allocator::size_type         size_type;
    typedef typename Allocator::difference_type   difference_type;
    typedef typename Allocator::pointer           pointer;
    typedef typename Allocator::const_pointer     const_pointer;
    typedef std::reverse_iterator<iterator>       reverse_iterator;
    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

    class value_compare: public binary_function<value_type,value_type,bool>{
    public:
        bool operator()(value_type const& x, value_type const& y)const{
            return comp(x.first, y.first);
        }

    protected:
        Compare comp;
        value_compare(Compare c):comp(c){}

    friend class multimap;
    };

// Konstruktoren, Destruktor, Kopieren
    explicit multimap(Compare const& comp = Compare(), Allocator const& = Allocator());

    template <typename InputIterator> multimap(
        InputIterator first,
        InputIterator last,
        Compare const& comp = Compare(),
        Allocator const& = Allocator()
    );

    multimap(multimap<Key,T,Compare,Allocator> const& x);

    ~multimap();

    multimap<Key,T,Compare,Allocator>& operator=(multimap<Key,T,Compare,Allocator> const& x);

    allocator_type get_allocator()const;

// Iteratoren
    iterator       begin();
    const_iterator begin()const;
    iterator       end();
    const_iterator end()const;

    reverse_iterator       rbegin();
    const_reverse_iterator rbegin()const;
    reverse_iterator       rend();
    const_reverse_iterator rend()const;

// Kapazität
    bool      empty()const;
    size_type size()const;
    size_type max_size()const;

// Modifizierer
    iterator insert(value_type const& x);
    iterator insert(iterator position, value_type& const x);
    template <typename InputIterator>
    void     insert(InputIterator first, InputIterator last);

    void      erase(iterator position);
    size_type erase(key_type const& x);
    void      erase(iterator first, iterator last);

    void swap(multimap<Key,T,Compare,Allocator>&);

    void clear();

// Betrachter
    key_compare   key_comp()const;
    value_compare value_comp()const;

// map-Operationen
    iterator       find(key_type const& x);
    const_iterator find(key_type const& x)const;

    size_type count(key_type const& x)const;

    iterator       lower_bound(key_type const& x);
    const_iterator lower_bound(key_type const& x)const;
    iterator       upper_bound(key_type const& x);
    const_iterator upper_bound(key_type const& x)const;

    pair<iterator,iterator>             equal_range(key_type const& x);
    pair<const_iterator,const_iterator> equal_range(key_type const& x)const;
};

// Vergleiche
template <typename Key, typename T, typename Compare, typename Allocator>
bool operator==(multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

template <typename Key, typename T, typename Compare, typename Allocator>
bool operator< (multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

template <typename Key, typename T, typename Compare, typename Allocator>
bool operator!=(multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

template <typename Key, typename T, typename Compare, typename Allocator>
bool operator> (multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

template <typename Key, typename T, typename Compare, typename Allocator>
bool operator>=(multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

template <typename Key, typename T, typename Compare, typename Allocator>
bool operator<=(multimap<Key,T,Compare,Allocator> const& x, multimap<Key,T,Compare,Allocator> const& y);

// Spezialisierte Algorithmen
template <typename Key, typename T, typename Compare, typename Allocator>
void swap(multimap<Key,T,Compare,Allocator>& x, multimap<Key,T,Compare,Allocator>& y);