template<typename K, typename V, template<typename T> class Greater = ops::Greater, template<typename T> class Less = ops::Less>
bpf::collection::Map class

Template parameters
K the key type
V the value type
Greater the greater than operator
Less the less than operator

AVL tree based map

Public types

struct Entry
struct Node
using Iterator = MapIterator<Map<K, V, Greater, Less>, Entry, Node>
using CIterator = MapConstIterator<Entry, Node>
using ReverseIterator = MapReverseIterator<Entry, Node>
using CReverseIterator = MapConstReverseIterator<Entry, Node>

Constructors, destructors, conversion operators

Map()
Map(const Map& other)
Map(Map&& other) noexcept
Map(const std::initializer_list<Entry>& entries)
~Map()

Public functions

void Add(const K& key, const V& value)
void Add(const K& key, V&& value)
void RemoveAt(const K& key)
void RemoveAt(Iterator& pos)
void RemoveAt(Iterator&& pos)
void Swap(const Iterator& a, const Iterator& b)
void Clear()
template<template<typename> class Comparator = ops::Equal>
void Remove(const V& value, bool all = true)
auto operator==(const Map<K, V, Greater, Less>& other) const -> bool noexcept
auto operator!=(const Map<K, V, Greater, Less>& other) const -> bool noexcept
auto FindByKey(const K& key) -> Iterator
template<template<typename> class Comparator = ops::Equal>
auto FindByValue(const V& val) -> Iterator
auto Find(const std::function<int(const Node&node)>& comparator) -> Iterator
auto operator[](const K& key) const -> const V&
auto FindMin() -> Iterator
auto FindMax() -> Iterator
auto operator[](const K& key) -> V&
auto operator=(const Map& other) -> Map&
auto operator=(Map&& other) -> Map& noexcept
auto operator+(const Map& other) const -> Map
void operator+=(const Map& other)
auto HasKey(const K& key) const -> bool
auto Size() const -> fsize
auto begin() const -> CIterator
auto end() const -> CIterator
auto begin() -> Iterator
auto end() -> Iterator
auto rbegin() const -> CReverseIterator
auto rend() const -> CReverseIterator
auto rbegin() -> ReverseIterator
auto rend() -> ReverseIterator

Function documentation

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bpf::collection::Map<K, V, Greater, Less>::Map()

Constructs an empty Map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bpf::collection::Map<K, V, Greater, Less>::Map(const Map& other)

Copy constructor

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bpf::collection::Map<K, V, Greater, Less>::Map(Map&& other) noexcept

Move constructor

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bpf::collection::Map<K, V, Greater, Less>::Map(const std::initializer_list<Entry>& entries)

Parameters
entries the initial list of key-value pairs to add to this new HashMap

Constructs a HashMap from an existing initializer list

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::Add(const K& key, const V& value)

Parameters
key the key of the element
value the value to insert

Adds a new element in this map, replaces if key already exists

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::Add(const K& key, V&& value)

Parameters
key the key of the element
value the value to insert

Adds a new element in this map, replaces if key already exists

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::RemoveAt(const K& key)

Parameters
key the key of the element to remove

Removes an element from the map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::RemoveAt(Iterator& pos)

Parameters
pos iterator of the element to remove, it is undefined behavior to pass a derived Iterator type

Removes an element from the map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::RemoveAt(Iterator&& pos)

Parameters
pos iterator of the element to remove, it is undefined behavior to pass a derived Iterator type

Removes an element from the map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::Swap(const Iterator& a, const Iterator& b)

Parameters
a first element
b second element

Swap two elements by iterator in the Map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::Clear()

Clears the content of this Map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less> template<template<typename> class Comparator = ops::Equal>
void bpf::collection::Map<K, V, Greater, Less>::Remove(const V& value, bool all = true)

Template parameters
Comparator the comparision operator to use for comparing values
Parameters
value the value to search for
all wether to remove all occurances or just the first one

Removes an element by value

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bool bpf::collection::Map<K, V, Greater, Less>::operator==(const Map<K, V, Greater, Less>& other) const noexcept

Parameters
other Map to compare with
Returns true if the two maps are equal, false otherwise

Compare Map by performing a per-element check

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bool bpf::collection::Map<K, V, Greater, Less>::operator!=(const Map<K, V, Greater, Less>& other) const noexcept

Parameters
other Map to compare with
Returns false if the two maps are equal, true otherwise

Compare Map by performing a per-element check

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::FindByKey(const K& key)

Parameters
key the key of the item to search for
Returns iterator to the found item or end() if none

Locate an item by key inside this map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less> template<template<typename> class Comparator = ops::Equal>
Iterator bpf::collection::Map<K, V, Greater, Less>::FindByValue(const V& val)

Template parameters
Comparator comparision operator to use
Parameters
val the value to search for
Returns iterator to the found item or end() if none

Locate an item by performing per-element check

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::Find(const std::function<int(const Node&node)>& comparator)

Parameters
comparator the comparision function to use: return Z- for less than, Z+ for greater than and 0 for equal
Returns iterator to the found item or end() if none

Locate an item by performing per-element check

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
const V& bpf::collection::Map<K, V, Greater, Less>::operator[](const K& key) const

Parameters
key the key of the element
Returns immutable item
Exceptions
IndexException if key is not in this map

Returns an element const mode

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::FindMin()

Returns iterator to the minimum element

Returns the element with the minimum key value

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::FindMax()

Returns iterator to the maximum element

Returns the element with the maximum key value

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
V& bpf::collection::Map<K, V, Greater, Less>::operator[](const K& key)

Parameters
key the key of the element
Returns mutable item
Exceptions
IndexException if key is not in this map and cannot be created

Returns an element non-const mode

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Map& bpf::collection::Map<K, V, Greater, Less>::operator=(const Map& other)

Copy assignment operator

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Map& bpf::collection::Map<K, V, Greater, Less>::operator=(Map&& other) noexcept

Move assignment operator

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Map bpf::collection::Map<K, V, Greater, Less>::operator+(const Map& other) const

Parameters
other map to concatenate with
Returns new Map

Create a new Map from concatenation of two maps

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
void bpf::collection::Map<K, V, Greater, Less>::operator+=(const Map& other)

Parameters
other map to append

Appends the content of a Map at the end of this map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
bool bpf::collection::Map<K, V, Greater, Less>::HasKey(const K& key) const

Parameters
key the key to check
Returns true if the specified key exists, false otherwise

Check if a particular key exists

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
fsize bpf::collection::Map<K, V, Greater, Less>::Size() const

Returns number of items as unsigned

Returns the number of items in this map

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
CIterator bpf::collection::Map<K, V, Greater, Less>::begin() const

Returns new iterator

Returns an iterator to the begining of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
CIterator bpf::collection::Map<K, V, Greater, Less>::end() const

Returns new iterator

Returns an iterator to the end of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::begin()

Returns new iterator

Returns an iterator to the begining of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
Iterator bpf::collection::Map<K, V, Greater, Less>::end()

Returns new iterator

Returns an iterator to the end of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
CReverseIterator bpf::collection::Map<K, V, Greater, Less>::rbegin() const

Returns new iterator

Returns a reverse iterator to the begining of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
CReverseIterator bpf::collection::Map<K, V, Greater, Less>::rend() const

Returns new iterator

Returns a reverse iterator to the end of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
ReverseIterator bpf::collection::Map<K, V, Greater, Less>::rbegin()

Returns new iterator

Returns a reverse iterator to the begining of the collection

template<typename K, typename V, template<typename T> class Greater, template<typename T> class Less>
ReverseIterator bpf::collection::Map<K, V, Greater, Less>::rend()

Returns new iterator

Returns a reverse iterator to the end of the collection