ORIGINAL
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1#ifndef MAP_H
2#define MAP_H
3
4#include "allocator.h"
5#include "container.h"
6#include "couple.h"
7
8
9
24
25namespace original {
26
46 template <typename K_TYPE,
47 typename V_TYPE,
49 class map : public container<couple<const K_TYPE, V_TYPE>, ALLOC> {
50 protected:
55 explicit map(ALLOC alloc = ALLOC{});
56
57 public:
65 virtual bool add(const K_TYPE& k, const V_TYPE& v) = 0;
66
73 virtual bool remove(const K_TYPE& k) = 0;
74
80 [[nodiscard]] virtual bool containsKey(const K_TYPE& k) const = 0;
81
88 virtual V_TYPE get(const K_TYPE& k) const = 0;
89
98 virtual bool update(const K_TYPE &key, const V_TYPE &value) = 0;
99
107 virtual const V_TYPE& operator[](const K_TYPE& k) const = 0;
108
118 virtual V_TYPE& operator[](const K_TYPE& k) = 0;
119
123 ~map() override;
124 };
125
126 template<typename K_TYPE, typename V_TYPE, typename ALLOC>
128 : container<couple<const K_TYPE, V_TYPE>, ALLOC>(std::move(alloc)) {}
129
130 template<typename K_TYPE, typename V_TYPE, typename ALLOC>
132}
133
134#endif //MAP_H
Memory allocation interface and implementations.
Default memory allocator using allocators utilities.
Definition allocator.h:154
Abstract base class for containers.
Definition container.h:28
Container for two heterogeneous elements.
Definition couple.h:37
virtual V_TYPE & operator[](const K_TYPE &k)=0
Non-const access to mapped values.
virtual V_TYPE get(const K_TYPE &k) const =0
Gets the value associated with a key.
~map() override
Virtual destructor.
map(ALLOC alloc=ALLOC{})
Constructs a map with the specified allocator.
Definition map.h:127
virtual bool containsKey(const K_TYPE &k) const =0
Checks if a key exists in the map.
virtual const V_TYPE & operator[](const K_TYPE &k) const =0
Const access to mapped values.
virtual bool remove(const K_TYPE &k)=0
Removes a key-value pair from the map.
virtual bool add(const K_TYPE &k, const V_TYPE &v)=0
Adds a new key-value pair to the map.
virtual bool update(const K_TYPE &key, const V_TYPE &value)=0
Updates the value for an existing key.
Abstract base class for container types.
Generic pair container implementation.
Main namespace for the project Original.
Definition algorithms.h:21