6#ifndef ACTIVE_CONTAINER_HASH_MAP
7#define ACTIVE_CONTAINER_HASH_MAP
9#include "Active/Utility/Cloner.h"
10#include "Active/Utility/Mover.h"
12#include <unordered_map>
26 class HashMap :
public std::unordered_map<Key, std::unique_ptr<T>> {
32 using base = std::unordered_map<Key, std::unique_ptr<T>>;
77 if (
this != &source) {
90 base::operator=(std::move(source));
106 auto find(
const Key& key)
const {
return base::find(key); }
128 emplace(item.first, std::move(item.second));
140 auto emplace(
const Key& key,
mapped_type&& item) {
return base::emplace(std::make_pair(key, std::move(item))); }
147 base::emplace(key, cloneMove(std::move(item)));
149 base::emplace(key, clone(item));
163 auto item = std::move(pos.second);
173 void cloneFrom(
const HashMap& source) {
174 for (
const auto& item : source)
175 base::
emplace(item.first, std::unique_ptr<T>{item.second ? clone(*item.second) : nullptr});
auto release(const_iterator pos)
Definition HashMap.h:162
auto find(const Key &key) const
Definition HashMap.h:106
auto insert(const value_type &item)
Definition HashMap.h:121
typename base::mapped_type mapped_type
Stored type.
Definition HashMap.h:36
typename base::iterator iterator
Container iterator type.
Definition HashMap.h:44
HashMap()
Definition HashMap.h:53
auto insert(value_type &&item)
Definition HashMap.h:127
virtual ~HashMap()=default
typename base::value_type value_type
Paired key/value type.
Definition HashMap.h:38
typename base::const_iterator const_iterator
Container const iterator type.
Definition HashMap.h:46
typename base::size_type size_type
Container size (index) type.
Definition HashMap.h:42
auto operator=(const HashMap &source)
Definition HashMap.h:76
HashMap(const HashMap &source)
Definition HashMap.h:58
HashMap(HashMap &&source)
Definition HashMap.h:63
auto emplace(const Key &key, mapped_type &&item)
Definition HashMap.h:140
auto insert(const raw_type &item)
Definition HashMap.h:115
std::unordered_map< Key, std::unique_ptr< T > > base
Base container type.
Definition HashMap.h:32
auto insert(node_type &&node)
Definition HashMap.h:135
auto release(iterator &pos)
Definition HashMap.h:156
typename base::node_type node_type
Node handle type.
Definition HashMap.h:40
auto emplace(const Key &key, T &&item)
Definition HashMap.h:145
std::pair< const Key, T > raw_type
Paired key/raw value type.
Definition HashMap.h:34
mapped_type & operator[](const Key &key)
Definition HashMap.h:98
Clonable concept for classes/functions dependent on cloning.
Definition Cloner.h:33
Movable concept for classes/functions dependent on cloning with a move.
Definition Mover.h:33