template<class T, bool RECURSE>
bsa::components::hashmap class

Establishes a basic mapping between a key and its associated files.

Template parameters
T The mapped_type.
RECURSE Determines if indexing via operator[] is a recursive action.

Public types

template<class U>
class index_t
A proxy value used to facilitate the usage/chaining of hashmap::operator[] in an intuitive manner.

Assignment

auto operator=(const hashmap&) -> hashmap& defaulted noexcept
auto operator=(hashmap&&) -> hashmap& defaulted noexcept

Capacity

auto empty() const -> bool noexcept
Checks if the container is empty.
auto size() const -> std::size_t noexcept
Returns the number of elements in the container.

Constructors

hashmap() defaulted noexcept
hashmap(const hashmap&) defaulted noexcept
hashmap(hashmap&&) defaulted noexcept

Destructor

~hashmap() defaulted noexcept

Iterators

auto begin() -> iterator noexcept
Obtains an interator to the beginning of the container.
auto begin() const -> const_iterator noexcept
Obtains an interator to the beginning of the container.
auto cbegin() const -> const_iterator noexcept
Obtains an interator to the beginning of the container.
auto cend() const -> const_iterator noexcept
Obtains an iterator to the end of the container.
auto end() -> iterator noexcept
Obtains an iterator to the end of the container.
auto end() const -> const_iterator noexcept
Obtains an iterator to the end of the container.

Lookup

auto find(const key_type& a_key) -> iterator noexcept
Finds a value_type with the given key within the container.
auto find(const key_type& a_key) const -> const_iterator noexcept
Finds a value_type with the given key within the container.
auto operator[](const key_type& a_key) -> index noexcept
Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.
auto operator[](const key_type& a_key) const -> const_index noexcept
Obtains a proxy to the underlying mapped_type. The validity of the proxy depends on the presence of the key within the container.

Member types

using const_index = index_t<const mapped_type>
using const_iterator = typename container_type::const_iterator
using index = index_t<mapped_type>
using iterator = typename container_type::iterator
using key_compare = typename container_type::key_compare
using key_type = typename T::key
using mapped_type = T
using value_type = std::pair<const key_type, mapped_type>

Modifiers

auto erase(const key_type& a_key) -> bool noexcept
Erases any element with the given key from the container.
auto insert(key_type a_key, mapped_type a_value) -> std::pair<iterator, bool> noexcept
Inserts a_value into the container with the given a_key.

Function documentation

template<class T, bool RECURSE>
bool bsa::components::hashmap<T, RECURSE>::erase(const key_type& a_key) noexcept

Erases any element with the given key from the container.

Returns Returns true if the element was successfully deleted, false otherwise.

template<class T, bool RECURSE>
std::pair<iterator, bool> bsa::components::hashmap<T, RECURSE>::insert(key_type a_key, mapped_type a_value) noexcept

Inserts a_value into the container with the given a_key.

Parameters
a_key The key of the value_type.
a_value The value of the value_type.
Returns Returns an iterator to the position at which the given value_type was inserted, and a bool to indicate if the insertion was successful.