# ace::HashVector< _StType, _HashFunc > Class Template Reference

Class for storage of. More...

`#include <hash_vector.h>`

List of all members.

## Public Types
typedef _StType | type
| Stored type definition.
typedef iterator | const_iterator
| Const iterator is simply iterator.
typedef std::pair< iterator, bool > | pair_ib
| Iterator and bool pair (insert method return value).
typedef std::pair< iterator, iterator > | pair_ii
| Pair of iterators (equal_range method return value).
## Public Member Functions
| HashVector (size_t init_size, size_t bucket_size, size_t crop_ratio)
| Constructor creates new hash table.
HashVector & | operator= (const HashVector &rhs)
| Assignment operator.
const_iterator | begin (void) const
const_iterator | end (void) const
pair_ib | insert (_StType value)
| Insert totally relies on caller! No checks (if item is already in) are performed!
pair_ii | equal_range (const _StType value) const
| Searches for given value and returns appropriate range.
size_t | size (void) const
void | sort (void)
| Sort items in all buckets according to their frequency.
## Private Types
typedef std::vector< _StType > | _store_t
| Container for items (to be stored) - aka bucket.
typedef std::vector< _store_t > | _buckets_t
| Container for buckets - aka hash table.
## Private Member Functions
void | _expand (void)
| Double sizes the buckets (hash table) and rehashes all containers.
## Private Attributes
size_t | _init_size
| We begin with _init_size buckets (shall be power of two).
size_t | _bucket_size
| How much items (in average) per bucket?
std::vector< _store_t > | _buckets
| Buckets (hash table).
_HashFunc | _h
| Hash function object.
size_t | _items
| Items counter.
size_t | _crop_ratio
| If capacity of vector is bigger than (crop ratio * its size), then we "crop" it.
## Classes
class | items_compare
| Function object for equal to comparison of two N-gram pointers (one passed as constructor param, second as unary operator() param). More...
class | items_sort
| Function object for less than comparison of two N-gram pointers which is based on frequencies of instances they point to. More...
class | iterator
| Iterator class needed (simple - only forward, no random access!). More...

## Detailed Description

### template<class _StType, class _HashFunc>
class ace::HashVector< _StType, _HashFunc >

Class for storage of.

Parameters:

  | _StType | Stored type (should be pointer to NGram).
  | _HashFunc | Hashing function type.

## Member Typedef Documentation

template<class _StType, class _HashFunc>

typedef _StType ace::HashVector< _StType, _HashFunc >::type

Stored type definition.

template<class _StType, class _HashFunc>

typedef std::vector<_StType> ace::HashVector< _StType, _HashFunc >::_store_t`[private]`

Container for items (to be stored) - aka bucket.

template<class _StType, class _HashFunc>

typedef std::vector<_store_t> ace::HashVector< _StType, _HashFunc >::_buckets_t`[private]`

Container for buckets - aka hash table.

template<class _StType, class _HashFunc>

typedef iterator ace::HashVector< _StType, _HashFunc >::const_iterator

Const iterator is simply iterator.

template<class _StType, class _HashFunc>

typedef std::pair<iterator, bool> ace::HashVector< _StType, _HashFunc >::pair_ib

Iterator and bool pair (insert method return value).

template<class _StType, class _HashFunc>

typedef std::pair<iterator, iterator> ace::HashVector< _StType, _HashFunc >::pair_ii

Pair of iterators (equal_range method return value).

## Constructor & Destructor Documentation

template<class _StType, class _HashFunc>

ace::HashVector< _StType, _HashFunc >::HashVector | ( | size_t | init_size,
|  | size_t | bucket_size,
|  | size_t | crop_ratio |
| ) |  |  | `[inline]`

Constructor creates new hash table.

Parameters:

  | init_size | Starting size of container.
  | bucket_size | Maximum allowed ratio of |items| / |buckets|.
  | crop_ratio | Crop ratio value.

## Member Function Documentation

template<class _StType, class _HashFunc>

void ace::HashVector< _StType, _HashFunc >::_expand | ( | void |  | ) | `[inline, private]`

Double sizes the buckets (hash table) and rehashes all containers.

template<class _StType, class _HashFunc>

HashVector& ace::HashVector< _StType, _HashFunc >::operator= | ( | const HashVector< _StType, _HashFunc > & | rhs | ) | `[inline]`

Assignment operator.

template<class _StType, class _HashFunc>

const_iterator ace::HashVector< _StType, _HashFunc >::begin | ( | void |  | ) | const`[inline]`

Returns:
  Iterator to the beginning of hash table.

template<class _StType, class _HashFunc>

const_iterator ace::HashVector< _StType, _HashFunc >::end | ( | void |  | ) | const`[inline]`

Returns:
  Iterator to the end of hash table.

template<class _StType, class _HashFunc>

pair_ib ace::HashVector< _StType, _HashFunc >::insert | ( | _StType | value | ) | `[inline]`

Insert totally relies on caller! No checks (if item is already in) are performed!

Parameters:

  | value | Value to be inserted.

Returns:
  Iterator pointing to inserted value and True. Every insert succeeds!

template<class _StType, class _HashFunc>

pair_ii ace::HashVector< _StType, _HashFunc >::equal_range | ( | const _StType | value | ) | const`[inline]`

Searches for given value and returns appropriate range.

Parameters:

  | value | Value to be searched.

Returns:
  Pair of iterators determining search results range.

template<class _StType, class _HashFunc>

size_t ace::HashVector< _StType, _HashFunc >::size | ( | void |  | ) | const`[inline]`

Returns:
  Number of items within container.

template<class _StType, class _HashFunc>

void ace::HashVector< _StType, _HashFunc >::sort | ( | void |  | ) | `[inline]`

Sort items in all buckets according to their frequency.

## Member Data Documentation

template<class _StType, class _HashFunc>

size_t ace::HashVector< _StType, _HashFunc >::_init_size`[private]`

We begin with _init_size buckets (shall be power of two).

template<class _StType, class _HashFunc>

size_t ace::HashVector< _StType, _HashFunc >::_bucket_size`[private]`

How much items (in average) per bucket?

template<class _StType, class _HashFunc>

std::vector<_store_t> ace::HashVector< _StType, _HashFunc >::_buckets`[private]`

Buckets (hash table).

template<class _StType, class _HashFunc>

_HashFunc ace::HashVector< _StType, _HashFunc >::_h`[private]`

Hash function object.

template<class _StType, class _HashFunc>

size_t ace::HashVector< _StType, _HashFunc >::_items`[private]`

Items counter.

template<class _StType, class _HashFunc>

size_t ace::HashVector< _StType, _HashFunc >::_crop_ratio`[private]`

If capacity of vector is bigger than (crop ratio * its size), then we "crop" it.

The documentation for this class was generated from the following file:

- proto/Source/hash_vector.h