로딩중...
검색중...
일치하는것 없음
tnchain.hpp
이 파일의 문서화 페이지로 가기
1
2#pragma once
3
5
6namespace by {
7
8 class node;
9
10 template <typename K, typename V, typename _defaultContainer = tnmap<K, V>>
11 class tnchain: public tnbicontainer<K, V> {
14 BY(CLASS(_me_, _super_))
15
16 public:
17 typedef typename super::iter iter;
18 typedef typename super::iteration iteration;
19 friend class nchainIteration;
22
23 public:
24 tnchain();
25 explicit tnchain(const super& arr);
26 explicit tnchain(const super& org, const me& next);
27 explicit tnchain(std::initializer_list<std::pair<K, V*>> elems);
28
29 public:
30 // has:
31 using super::in;
32 nbool in(const K& key) const override;
33
34 // len:
35 ncnt len() const override;
36 ncnt chainLen() const;
37
38 using super::get;
39 V* get(const K& key) override;
40
41 // add:
42 using super::add;
43 nbool add(const K& key, const V& val) override;
44
59 virtual nbool link(const iter& portion);
60 nbool link(const me& new1);
61 nbool link(const me* it) BY_SIDE_FUNC(link);
62 nbool unlink();
63
64 // del:
65 using super::del;
69 nbool del(const K& key) override;
70 nbool del(const iter& at) override;
71 nbool del(const iter& from, const iter& end) override;
72
73 // etc:
74 void rel() override;
75
76 super& getContainer();
77 const super& getContainer() const;
78
79 me* getNext();
80 const me* getNext() const BY_CONST_FUNC(getNext())
81
82 me* getPrev();
84
88 me* getTail();
90
96 void onCloneDeep(const clonable& from) override;
97
106 T* ret = (T*) toShallowWrap.template cast<T>();
107 if(!ret) {
108 ret = new T();
109 ret->_map.bind(toShallowWrap);
110 }
111
112 return ret;
113 }
114
115 template <typename T> static T* wrap(const super* it) BY_SIDE_FUNC(it, wrap<T>(*it), nullptr);
116
117 static me* wrap(const super& toShallowWrap);
118 static me* wrap(const super* it) BY_SIDE_FUNC(wrap);
119
126 me* cloneChain(const super* until) const;
127 me* cloneChain(const me* until) const;
128
132 me* cloneChain() const;
133
134 protected:
135 iteration* _onMakeIteration(const K* key, nbool isReversed, ncnt step, nbool isBoundary) const override;
136
137 void _getAll(const K& key, narr& tray) const override;
138
139 private:
140 iter* _getInnerIter(const iter& wrapper);
141 iter _getInnerBeginOfChain(me& it, const me& fromChain, const iter& from);
142 iter _getInnerEndOfChain(me& it, const me& lastChain, const iter& last);
143 iter _rendOfThisChain(nbool isReversed);
144 me& _getLastChain();
145 void _eachChain(std::function<void(me&)> closure);
146
147 private:
148 tstr<super> _map;
149 iter _next;
150 iter _prev;
151 };
152
155} // namespace by
Scripted array container for byeol language
Definition arr.hpp:15
func closure with captured object scope
Definition closure.hpp:20
Definition tnarr.hpp:9
Definition tnbicontainer.hpp:8
Definition tnchain.hpp:11
static T * wrap(const super &toShallowWrap)
Definition tnchain.hpp:105
const me * getPrev() const BY_CONST_FUNC(getPrev()) me *getTail()
virtual nbool link(const iter &portion)
link to another chain instance. if iterator is not the begin of another chain, this chain won't link ...
me * cloneChain() const
const me * getTail() const BY_CONST_FUNC(getTail()) void onCloneDeep(const clonable &from) override
nbool del(const K &key) override
me * cloneChain(const super *until) const
Bidirectional iterator for key-value containers
Definition biter.hpp:10
Definition biteration.hpp:5
Chain iteration implementation
Definition nchainIteration.hpp:8
to Top