# Poco

# template < class Key, class Mapped, class HashFunc = Hash < Key >>

# class HashMap

Library: Foundation
Package: Hashing
Header: Poco/HashMap.h

## Description

This class implements a map using a LinearHashTable.

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

## Member Summary

Member Functions: begin, clear, count, empty, end, erase, find, insert, operator =, operator [], size, swap

## Types Aliases

### ConstIterator

using ConstIterator = typename HashTable::ConstIterator;

### ConstPointer

using ConstPointer = const Mapped *;

### ConstReference

using ConstReference = const Mapped &;

### HashTable

using HashTable = LinearHashTable < ValueType, HashType >;

### HashType

using HashType = HashMapEntryHash < ValueType, HashFunc >;

### Iterator

using Iterator = typename HashTable::Iterator;

### KeyType

using KeyType = Key;

### MappedType

using MappedType = Mapped;

### PairType

using PairType = std::pair < KeyType, MappedType >;

### Pointer

using Pointer = Mapped *;

### Reference

using Reference = Mapped &;

### ValueType

using ValueType = HashMapEntry < Key, Mapped >;

## Constructors

### HashMap

HashMap() = default;

### HashMap

HashMap(
std::size_t initialReserve
);

Creates the HashMap with room for initialReserve entries.

## Member Functions

### begin

ConstIterator begin() const;

### begin

Iterator begin();

### clear

void clear();

### count

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

### empty

bool empty() const;

### end

ConstIterator end() const;

### end

Iterator end();

### erase

void erase(
Iterator it
);

### erase

void erase(
const KeyType & key
);

### find

ConstIterator find(
const KeyType & key
) const;

### find

Iterator find(
const KeyType & key
);

### insert

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

### insert

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

### operator =

HashMap & operator = (
const HashMap & map
);

Assigns another HashMap.

### operator []

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

### operator []

Reference operator[] (
const KeyType & key
);

### size

std::size_t size() const;

### swap

void swap(
HashMap & map
) noexcept;

Swaps the HashMap with another one.