38template <
class _K, 
class _D> 
class mapData {
 
   66        if ((this->key == val.
key) && (this->data == val.
data)) {
 
 
 
   79template <
class _K, 
class _D> 
class map {
 
   88        this->content.clear();
 
 
  100        this->content.reserve(init_list.size()); 
 
  101        for (
const auto& element : init_list) {
 
  102            this->content.push_back(element);
 
 
  112        this->content.push_back(element);
 
 
  122        this->content.push_back(element);
 
 
  130        if (this->
get(element.
key) != NULL)
 
  131            throw std::runtime_error(
"lib::map - Key already exist!");
 
 
  141        if (this->
get(key) != NULL)
 
  142            throw std::runtime_error(
"lib::map - Key already exist!");
 
 
  151        this->content.pop_back();
 
 
  160        if (this->content.empty())
 
  162        for (
unsigned int i = 0; i < this->content.size(); i++) {
 
  164            if (elem->
key == key) {
 
  165                return &(elem->
data);
 
 
  176        if (this->content.empty())
 
  178        for (
unsigned int i = 0; i < this->content.size(); i++) {
 
  180            if (elem->
key == key) {
 
 
  207            if (data.data == value)
 
 
  216        this->content.clear();
 
 
  224        return this->content.at(i);
 
 
  233        return &(this->content.at(i));
 
 
  240        if (idx >= this->content.size())
 
  242        this->content.erase(std::next(this->content.begin(), idx));
 
 
  249        __SIZE_TYPE__ idx = this->content.size();
 
  250        for (
unsigned int i = 0; i < this->content.size(); i++) {
 
  252            if (elem.
key == key) {
 
  256        if (idx >= this->content.size())
 
  258        this->content.erase(std::next(this->content.begin(), idx));
 
 
  266        for (
auto elem : this->
content) {
 
  267            ret.push_back(elem.key);
 
 
  276        return this->content.size();
 
 
  284        return this->content.at(i);
 
 
  351        this->content.clear();
 
  352        this->content.push_back(val);
 
 
  361        if (this->content.size() != val.
content.size())
 
  363        for (__SIZE_TYPE__ i = 0; i < this->content.size(); i++) {
 
  364            if (this->content.at(i) != val.
content.at(i))
 
 
  373    typename std::vector<mapData<_K, _D>>::iterator 
begin() {
 
  374        return this->content.begin();
 
 
  380    typename std::vector<mapData<_K, _D>>::iterator 
end() {
 
  381        return this->content.end();
 
 
  388    typename std::vector<mapData<_K, _D>>::const_iterator 
begin()
 const {
 
  389        return this->content.begin();
 
 
  396    typename std::vector<mapData<_K, _D>>::const_iterator 
end()
 const {
 
  397        return this->content.end();
 
 
  403        return this->content.empty();
 
 
  406        for (
unsigned int i = 0; i < this->content.size(); i++) {
 
  407            if (this->content.at(i).key == key) {
 
  408                this->content.erase(this->content.begin() + i);
 
 
 
 
Simple pair of values, have "==" operator implemented.
 
mapData(_K key, _D data)
Construct a new map data object.
 
mapData()
Construct a new map data object,  ! Key and data variables is not initialize and contains garbage.
 
bool operator==(lib::mapData< _K, _D > val)
If ((this.key == val.key) && (this.data == val.data))
 
Simple map implementation with some stack operation added.
 
void push_back(_K key, _D data)
Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.
 
bool empty()
Simmilar to std::vector::empty.
 
bool contains_key(_K key)
Does map contains some key.
 
void remove(__SIZE_TYPE__ idx)
Remove element from map and return copy of this element.
 
std::vector< mapData< _K, _D > > content
 
void push_back_check(lib::mapData< _K, _D > element)
Add data, but check if key exists, if exist - trow exception.
 
lib::mapData< _K, _D > pop_back()
Pop last element, remove it and return back it's copy.
 
std::vector< mapData< _K, _D > >::iterator begin()
Begin iterator.
 
std::vector< _K > keys()
Get keys list.
 
lib::map< _K, _D > operator+=(lib::mapData< _K, _D > val)
Add one element to map, modify it.
 
lib::mapData< _K, _D > * ptr_at(__SIZE_TYPE__ i)
Array operation, get pointer to an element at specified index.
 
map(map const &)=default
Copy constructor.
 
__SIZE_TYPE__ size()
Size of map.
 
map(std::initializer_list< lib::mapData< _K, _D > > init_list)
Consruct a new map object and initialize it.
 
void remove(_K key)
Remove element with given key.
 
std::vector< mapData< _K, _D > >::const_iterator end() const
End const iterator.
 
lib::map< _K, _D > operator=(lib::map< _K, _D > val)
Copy content of second map to first.
 
void clear()
Erase all elements (simmilar to std::vector::clear())
 
bool contains(_D value)
Does map contains some value.
 
lib::map< _K, _D > operator+(lib::mapData< _K, _D > val)
Add one elment to map.
 
map()
Construct a new map object.
 
lib::map< _K, _D > operator+(lib::map< _K, _D > val)
Add another map to this map.
 
void push_back(lib::mapData< _K, _D > element)
Push new element to map, stack operation ! Dangerous not perform chak if this elemnt exists in map.
 
const _D * get(_K key)
Get element by it's key.
 
lib::mapData< _K, _D > operator[](__SIZE_TYPE__ i)
Typical array operation, simmilar to at but using operator [].
 
lib::map< _K, _D > operator+=(lib::map< _K, _D > val)
Add another map to this, modify it.
 
bool operator==(lib::map< _K, _D > val)
Check if content of two maps is equal.
 
std::vector< mapData< _K, _D > >::iterator end()
End iterator.
 
void push_back_check(_K key, _D data)
Add data, but check if key exists, if exist - trow exception.
 
lib::mapData< _K, _D > at(__SIZE_TYPE__ i)
Array operation, get element at index.
 
lib::mapData< _K, _D > * get_ptr(_K key)
Get reference to key and value of map.
 
lib::map< _K, _D > operator=(lib::mapData< _K, _D > val)
Reset map, set first it's element to val.
 
std::vector< mapData< _K, _D > >::const_iterator begin() const
Begin const iterator.