<commit_before>/*!
    \file hashmap.h
    \brief Hash map container definition
    \author <NAME>
    \date 11.07.2017
    \copyright MIT License
*/

#ifndef CPPCOMMON_CONTAINERS_HASHMAP_H
#define CPPCOMMON_CONTAINERS_HASHMAP_H

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iterator>
#include <vector>

namespace CppCommon {

template <typename TContainer, typename TKey, typename TValue>
class HashMapIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapConstIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapReverseIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapConstReverseIterator;

//! Hash map container
/*!
    Hash map is an efficient  structure  for  associative  keys/value  storing
    and accessing. It uses  hash function  to  convert  string  key  into  the
    integer and use the index to quick access value data.

    Open  address  hash map resolves collisions of the  same  hash  values  by
    inserting new item into the next free place (probing with step 1).
*/
template <typename TKey, typename TValue, typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<const TKey, TValue>>>
class HashMap
{
    friend class HashMapIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapConstIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapConstReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;

public:
    // Standard container type definitions
    typedef TKey key_type;
    typedef TValue mapped_type;
    typedef std::pair<TKey, TValue> value_type;
    typedef value_type& reference;
    typedef const value_type& const_reference;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef ptrdiff_t difference_type;
    typedef size_t size_type;
    typedef HashMapIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> iterator;<commit_msg>build<commit_after>/*!
    \file hashmap.h
    \brief Hash map container definition
    \author <NAME>
    \date 11.07.2017
    \copyright MIT License
*/

#ifndef CPPCOMMON_CONTAINERS_HASHMAP_H
#define CPPCOMMON_CONTAINERS_HASHMAP_H

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iterator>
#include <vector>

namespace CppCommon {

template <typename TContainer, typename TKey, typename TValue>
class HashMapIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapConstIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapReverseIterator;
template <typename TContainer, typename TKey, typename TValue>
class HashMapConstReverseIterator;

//! Hash map container
/*!
    Hash map is an efficient  structure  for  associative  keys/value  storing
    and accessing. It uses  hash function  to  convert  string  key  into  the
    integer and use the index to quick access value data.

    Open  address  hash map resolves collisions of the  same  hash  values  by
    inserting new item into the next free place (probing with step 1).
*/
template <typename TKey, typename TValue, typename THash = std::hash<TKey>, typename TEqual = std::equal_to<TKey>, typename TAllocator = std::allocator<std::pair<TKey, TValue>>>
class HashMap
{
    friend class HashMapIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapConstIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;
    friend class HashMapConstReverseIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue>;

public:
    // Standard container type definitions
    typedef TKey key_type;
    typedef TValue mapped_type;
    typedef std::pair<TKey, TValue> value_type;
    typedef value_type& reference;
    typedef const value_type& const_reference;
    typedef value_type* pointer;
    typedef const value_type* const_pointer;
    typedef ptrdiff_t difference_type;
    typedef size_t size_type;
    typedef HashMapIterator<HashMap<TKey, TValue, THash, TEqual, TAllocator>, TKey, TValue> iterator;
{'fraction_non_alphanumeric': 0.07825700311249444, 'fraction_numerical': 0.004001778568252557, 'mean_word_length': 4.919736842105263, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2985223', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1318, 'n_words': 450}