Poco

template < class Value, class HashFunc = Hash < Value >>

class HashSet

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

Description

This class implements a set using a LinearHashTable.

A HashSet can be used just like a std::set.

Member Summary

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

Types

ConstIterator

typedef typename HashTable::ConstIterator ConstIterator;

ConstPointer

typedef const Value * ConstPointer;

ConstReference

typedef const Value & ConstReference;

Hash

typedef HashFunc Hash;

HashTable

typedef LinearHashTable < ValueType, Hash > HashTable;

Iterator

typedef typename HashTable::Iterator Iterator;

Pointer

typedef Value * Pointer;

Reference

typedef Value & Reference;

ValueType

typedef Value ValueType;

Constructors

HashSet inline

HashSet();

Creates an empty HashSet.

HashSet inline

HashSet(
    std::size_t initialReserve
);

Creates the HashSet, using the given initialReserve.

HashSet inline

HashSet(
    const HashSet & set
);

Creates the HashSet by copying another one.

Destructor

~HashSet inline

~HashSet();

Destroys the HashSet.

Member Functions

begin inline

ConstIterator begin() const;

Returns an iterator pointing to the first entry, if one exists.

begin inline

Iterator begin();

Returns an iterator pointing to the first entry, if one exists.

clear inline

void clear();

Erases all elements.

count inline

std::size_t count(
    const ValueType & value
) const;

Returns the number of elements with the given value, with is either 1 or 0.

empty inline

bool empty() const;

Returns true iff the table is empty.

end inline

ConstIterator end() const;

Returns an iterator pointing to the end of the table.

end inline

Iterator end();

Returns an iterator pointing to the end of the table.

erase inline

void erase(
    Iterator it
);

Erases the element pointed to by it.

erase inline

void erase(
    const ValueType & value
);

Erases the element with the given value, if it exists.

find inline

ConstIterator find(
    const ValueType & value
) const;

Finds an entry in the table.

find inline

Iterator find(
    const ValueType & value
);

Finds an entry in the table.

insert inline

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

Inserts an element into the set.

If the element already exists in the set, a pair(iterator, false) with iterator pointing to the existing element is returned. Otherwise, the element is inserted an a pair(iterator, true) with iterator pointing to the new element is returned.

operator = inline

HashSet & operator = (
    const HashSet & table
);

Assigns another HashSet.

size inline

std::size_t size() const;

Returns the number of elements in the table.

swap inline

void swap(
    HashSet & set
);

Swaps the HashSet with another one.