로딩중...
검색중...
일치하는것 없음
biter.inl
1// nested class of tbicontainable.inl:
2// this file allows to be refered by 'tbicontainable.inl' file only.
3#pragma once
4
5#include "core/ast/node.hpp"
6
7namespace by {
8
9#define TEMPL template <typename K, typename V>
10#define ME tbicontainable<K, V>::iter
11
12 TEMPL
13 ME::iter(): me(nullptr) {}
14
15 TEMPL
16 ME::iter(iteration* newStep): _iteration(newStep) {}
17
18 TEMPL
19 ME::iter(const me& rhs) { _assign(rhs); }
20
21 TEMPL
22 typename ME ME::operator+(ncnt step) {
23 ME ret = *this;
24 ret.next(step);
25 return ret;
26 }
27
28 TEMPL
29 typename ME& ME::operator++() {
30 next(1);
31 return *this;
32 }
33
34 TEMPL
35 typename ME ME::operator++(int) {
36 me ret = *this;
37 next(1);
38 return ret;
39 }
40
41 TEMPL
42 typename ME& ME::operator+=(ncnt step) {
43 next(step);
44 return *this;
45 }
46
47 TEMPL
48 V& ME::operator*() { return *getVal(); }
49
50 TEMPL
51 V* ME::operator->() { return getVal(); }
52
53 TEMPL
54 typename ME& ME::operator=(const me& rhs) {
55 _assign(rhs);
56 return *this;
57 }
58
59 TEMPL
60 ME::operator nbool() const { return !isEnd(); }
61
62 TEMPL
63 nbool ME::isReversed() const { return _iteration ? _iteration->isReversed() : false; }
64
65 TEMPL
66 void ME::rel() { _iteration TO(rel()); }
67
68 TEMPL
69 nbool ME::isFrom(const tbicontainable& it) const {
70 WHEN(!_iteration) .ret(false);
71 return _iteration->isFrom(it);
72 }
73
74 TEMPL
75 nbool ME::isEnd() const { return _iteration ? _iteration->isEnd() : true; }
76
77 TEMPL
78 ncnt ME::_step(typename iterable::iterationType type, ncnt step) {
79 WHEN_NUL(_iteration).ret(0);
80
81 for(int n = 0; n < step; n++) {
82 if(_iterate(type) <= 0) return n;
83 _nextToMatchParamType(type);
84 }
85
86 return step;
87 }
88
89 TEMPL
90 ncnt ME::next(ncnt step) { return _step(iterable::NEXT, step); }
91
92 TEMPL
93 ncnt ME::prev(ncnt step) { return _step(iterable::PREV, step); }
94
95 TEMPL
96 ncnt ME::stepForward(ncnt step) { return _step(iterable::FORWARD, step); }
97
98 TEMPL
99 ncnt ME::stepBackward(ncnt step) { return _step(iterable::BACKWARD, step); }
100
101 TEMPL
102 const K* ME::getKey() const { return _iteration ? _iteration->getKey() : nullptr; }
103
104 TEMPL
105 V* ME::getVal() { return _iteration ? _iteration->getVal() : nullptr; }
106
107 TEMPL
108 void ME::setVal(const V& new1) {
109 if(_iteration) _iteration->setVal(new1);
110 }
111
112 TEMPL
113 tbicontainable<K, V>* ME::getContainer() { return _iteration ? _iteration->getContainer() : nullptr; }
114
115 TEMPL
116 typename ME& ME::_assign(const me& rhs) {
117 _iteration.bind(rhs._iteration ? (iteration*) rhs._iteration->clone() : nullptr);
118 return *this;
119 }
120
121 TEMPL
122 nbool ME::_onSame(const typeProvidable& rhs) const {
123 const me& cast = (const me&) rhs;
124 return _iteration == cast._iteration;
125 }
126
127 TEMPL
128 void ME::_nextToMatchParamType(typename iterable::iterationType type) {
129 while(!isEnd()) {
130 WHEN(getVal()) .ret();
131 _iterate(type);
132 }
133 }
134
135 TEMPL
136 ncnt ME::_iterate(typename iterable::iterationType type) {
137 WHEN_NUL(_iteration).ret(BY_INDEX_ERROR);
138 switch(type) {
139 case iterable::FORWARD: return _iteration->stepForward(1);
140 case iterable::BACKWARD: return _iteration->stepBackward(1);
141 case iterable::PREV: return _iteration->prev(1);
142 default:
143 case iterable::NEXT: return _iteration->next(1);
144 }
145 }
146
147#undef ME
148#undef TEMPL
149} // namespace by
Definition biteration.hpp:5
to Top