template class Poco::HashMap

Overview

This class implements a map using a LinearHashTable. Moreā€¦

#include <HashMap.h>

template <
    class Key,
    class Mapped,
    class HashFunc = Hash<Key>
    >
class HashMap
{
public:
    // typedefs

    typedef Key KeyType;
    typedef Mapped MappedType;
    typedef Mapped& Reference;
    typedef const Mapped& ConstReference;
    typedef Mapped* Pointer;
    typedef const Mapped* ConstPointer;
    typedef HashMapEntry<Key, Mapped> ValueType;
    typedef std::pair<KeyType, MappedType> PairType;
    typedef HashMapEntryHash<ValueType, HashFunc> HashType;
    typedef LinearHashTable<ValueType, HashType> HashTable;
    typedef HashTable::Iterator Iterator;
    typedef HashTable::ConstIterator ConstIterator;

    // construction

    HashMap();
    HashMap(std::size_t initialReserve);

    // methods

    HashMap&
    operator=(const HashMap& map);

    void
    swap(HashMap& map);

    ConstIterator
    begin() const;

    ConstIterator
    end() const;

    Iterator
    begin();

    Iterator
    end();

    ConstIterator
    find(const KeyType& key) const;

    Iterator
    find(const KeyType& key);

    std::size_t
    count(const KeyType& key) const;

    std::pair<Iterator, bool>
    insert(const PairType& pair);

    std::pair<Iterator, bool>
    insert(const ValueType& value);

    void
    erase(Iterator it);

    void
    erase(const KeyType& key);

    void
    clear();

    std::size_t
    size() const;

    bool
    empty() const;

    ConstReference
    operator[](const KeyType& key) const;

    Reference
    operator[](const KeyType& key);
};

Detailed Documentation

This class implements a map using a LinearHashTable.

A HashMap can be used just like a std::map.

Construction

HashMap()

Creates an empty HashMap.

Methods

HashMap&
operator=(const HashMap& map)

Assigns another HashMap.

void
swap(HashMap& map)

Swaps the HashMap with another one.