tbicontainable.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "core/ast/param.hpp"
5
6namespace by {
7
8 class node;
9 template <typename K, typename V> class tnbicontainer;
10 template <typename T, typename TACTIC> class tnarr;
11 typedef class _nout tnarr<node, strTactic> narr;
12
17 template <typename K, typename V> class tbicontainable {
18 BY_ME(tbicontainable)
19 template <typename K1, typename V1, typename defaultContainer> friend class tnchain;
20
21 public:
23
24 public:
25 virtual ~tbicontainable();
26
27 // operator:
28 V& operator[](const K& key);
29
30 const V& operator[](const K& key) const;
31
32 // len:
33 virtual ncnt len() const = 0;
34
35 ncnt isEmpty() const;
36
37 // has:
38 virtual nbool in(const K& key) const = 0;
39 nbool in(const K* it) const BY_SIDE_FUNC(in);
40 nbool in(const V& val) const;
41 nbool in(const V* it) const BY_SIDE_FUNC(in);
42 nbool in(std::function<nbool(const K& key, const V& val)> l) const;
43 template <typename V1> nbool in(std::function<nbool(const K& key, const V1& val)> l) const;
44
45 // get:
46 virtual V* get(const K& key) = 0;
47 const V* get(const K& key) const BY_CONST_FUNC(get(key))
48 V* get(const K* it) BY_SIDE_FUNC(get);
49 template <typename V1> V1* get();
50 template <typename V1> const V1* get() const BY_CONST_FUNC(get<V1>())
51 template <typename V1> V1* get(const K& key);
52 template <typename V1> const V1* get(const K& key) const BY_CONST_FUNC(get<V1>(key))
53 template <typename V1> V1* get(const K* it) BY_SIDE_FUNC(get<V1>);
54 template <typename V1> const V1* get(const K* key) const BY_CONST_FUNC(get<V1>(key))
55 template <typename V1> V1* get(std::function<nbool(const K&, const V1&)> l);
56 V* get(std::function<nbool(const K&, const V&)> l);
57 template <typename V1> const V1* get(std::function<nbool(const K&, const V1&)> l) const BY_CONST_FUNC(get(l))
58 const V* get(std::function<nbool(const K&, const V&)> l) const BY_CONST_FUNC(get(l))
59
60 tnarr<V, strTactic> getAll(const K& key) const;
61 tnarr<V, strTactic> getAll(const K* it) const BY_SIDE_FUNC(getAll);
62 template <typename V1> tnarr<V1, strTactic> getAll() const;
63 template <typename V1> tnarr<V1, strTactic> getAll(std::function<nbool(const K&, const V1&)> l) const;
64 tnarr<V, strTactic> getAll(std::function<nbool(const K&, const V&)> l) const;
65
66 template <typename V1> void each(std::function<nbool(const K&, V1&)> l);
67 void each(std::function<nbool(const K&, V&)> l);
68 template <typename V1> void each(std::function<nbool(const K&, const V1&)> l) const BY_CONST_FUNC(each(l))
69 void each(std::function<nbool(const K&, const V&)> l) const BY_CONST_FUNC(each(l))
70
71 // iter:
72 iter begin() const;
73 iter begin(const K& key) const;
74 iter begin(const K* it) const BY_SIDE_FUNC(it, begin(*it), iterate(0));
75
76 iter rbegin() const;
77 iter rbegin(const K& key) const;
78 iter rbegin(const K* it) const BY_SIDE_FUNC(it, rbegin(*it), riterate(0));
79
80 virtual iter end() const;
81
82 virtual iter rend() const;
83
84 virtual iter last() const;
85
86 iter iterate(ncnt step) const;
87
98 iter iterate(ncnt step, nbool isBoundary) const;
99 iter iterate(const K& key) const;
100 iter iterate(const K* it) const BY_SIDE_FUNC(it, iterate(*it), begin());
101 iter iterate(const K& key, nbool isBoundary) const;
102 iter iterate(const K* key, nbool isBoundary) const
103 BY_SIDE_FUNC(key, iterate(*key, isBoundary), iterate(0, isBoundary));
104 iter riterate(ncnt step) const;
105 iter riterate(ncnt step, nbool isBoundary) const;
106 iter riterate(const K& key) const;
107 iter riterate(const K* it) const BY_SIDE_FUNC(it, riterate(*it), rbegin());
108 iter riterate(const K& key, nbool isBoundary) const;
109 iter riterate(const K* key, nbool isBoundary) const
110 BY_SIDE_FUNC(key, riterate(*key, isBoundary), riterate(0, isBoundary));
111
112 virtual nbool add(const K& key, const V& val) = 0;
113 nbool add(const K* key, const V& val) BY_SIDE_FUNC(key, add(*key, val), false);
114 nbool add(const K& key, const V* val) BY_SIDE_FUNC(val, add(key, *val), false);
115 nbool add(const K* key, const V* val) BY_SIDE_FUNC(key || val, add(*key, *val), false);
116 ncnt add(const iter& from, const iter& to);
117 ncnt add(const tbicontainable& rhs);
118 ncnt add(const tbicontainable* it) BY_SIDE_FUNC(add);
119
122 virtual nbool del(const K& key) = 0;
123 nbool del(const K* it) BY_SIDE_FUNC(del);
124 virtual nbool del(const iter& at) = 0;
125 nbool del(const iter* it) BY_SIDE_FUNC(del);
126 virtual nbool del(const iter& from, const iter& end) = 0;
127 nbool del(const iter* from, const iter& end) BY_SIDE_FUNC(from, del(*from, end), false);
128 nbool del(const iter& from, const iter* end) BY_SIDE_FUNC(end, del(from, *end), false);
129 nbool del(const iter* from, const iter* end) BY_SIDE_FUNC(from&& end, del(*from, *end), false);
130
131 nbool del(const tbicontainable& rhs);
132 nbool del(const tbicontainable* it) BY_SIDE_FUNC(del);
133
134 // etc:
135 virtual void rel() = 0;
136
137 protected:
138 virtual iteration* _onMakeIteration(const K* key, nbool isReversed, ncnt step, nbool isBoundary) const = 0;
139 virtual void _getAll(const K& key, narr& tray) const = 0;
140 };
141
143} // namespace by
Deferred execution utility like defer keyword in other languages.
Definition: end.hpp:14
Template bidirectional container interface.
Definition: tbicontainable.hpp:17
virtual nbool del(const K &key)=0
iter iterate(ncnt step, nbool isBoundary) const
Definition: tnarr.hpp:9
Definition: tnchain.hpp:11
Bidirectional iterator for key-value containers.
Definition: biter.hpp:9
Definition: biteration.hpp:5