# 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

### ConstIterator

typedef typename HashTable::ConstIterator ConstIterator;

### ConstPointer

typedef const Mapped * ConstPointer;

### ConstReference

typedef const Mapped & ConstReference;

### HashTable

typedef LinearHashTable < ValueType, HashType > HashTable;

### HashType

typedef HashMapEntryHash < ValueType, HashFunc > HashType;

### Iterator

typedef typename HashTable::Iterator Iterator;

### KeyType

typedef Key KeyType;

### MappedType

typedef Mapped MappedType;

### PairType

typedef std::pair < KeyType, MappedType > PairType;

### Pointer

typedef Mapped * Pointer;

### Reference

typedef Mapped & Reference;

### ValueType

typedef HashMapEntry < Key, Mapped > ValueType;

## Constructors

### HashMap

HashMap();

Creates an empty HashMap.

### 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
);

Swaps the HashMap with another one.