5#include "core/builtin/container/native/tnbicontainer.inl"
9#define TEMPL template <typename K, typename V, typename TACTIC>
10#define ME tnmap<K, V, TACTIC>
16 ME::tnmap(
const std::initializer_list<std::pair<K, V*>>& elems) {
17 for(
const auto& e: elems)
18 add(e.first, *e.second);
22 nbool ME::in(
const K& key)
const {
return _map.begin(key) != _map.end(); }
25 V* ME::get(
const K& key) {
26 WHEN(!in(key)) .ret(
nullptr);
28 return _map.begin(key).getVal() TO(get());
32 typename ME::iteration* ME::_onMakeIteration(
const K* key, nbool isReversed, ncnt step, nbool)
const {
33 me* unconst =
const_cast<me*
>(
this);
40 void ME::_getAll(
const K& key, narr& tray)
const {
41 auto end = _map.end();
42 for(
auto e = _map.begin(key); e != end; ++e)
43 tray.add(e.getVal() TO(get()));
47 typename ME::nmapIteration* ME::_getIterationFrom(
const iter& it) {
48 WHEN(!it.isFrom(*
this)) .warn(
"from is not an iterator of this container.").ret(
nullptr);
53 nbool ME::add(
const K& key,
const V& new1) {
54 _map.insert(key, wrap(new1));
59 nbool ME::del(
const K& key) {
65 nbool ME::del(
const iter& at) {
66 WHEN(at.isEnd()) .warn(
"at is end of the container. skip function.").ret(
false);
75 nbool ME::del(
const iter& from,
const iter& end) {
78 _map.erase(fromE._citer, endE._citer);
84 ncnt ME::len()
const {
return _map.size(); };
87 void ME::rel() { _map.clear(); }
90 void ME::onCloneDeep(
const clonable& from) {
93 for(
iter e = rhs.begin(); e; ++e)
94 add(e.getKey(), (V*) (e.getVal() TO(cloneDeep())));
Bidirectional iterator for key-value containers
Definition biter.hpp:10
Definition nmapIteration.hpp:6