13 template<
typename TYPE>
16 template<
typename TYPE>
19 template<
typename TYPE>
22 template<
typename TYPE,
typename Callback>
26 template<
typename TYPE,
typename Callback>
30 template<
typename TYPE,
typename Callback>
34 template<
typename TYPE>
37 template<
typename TYPE>
40 template<
typename TYPE,
typename Callback>
45 template<
typename TYPE,
typename Callback>
49 template<
typename TYPE>
52 template<
typename TYPE,
typename Callback>
56 template<
typename TYPE>
60 template<
typename TYPE,
typename Callback>
65 template<
typename TYPE,
typename Callback>
69 template<
typename TYPE,
typename Callback_O,
typename Callback_C>
73 template<
typename TYPE,
typename Callback_O,
typename Callback_C>
77 template<
typename TYPE>
81 template<
typename TYPE>
84 template<
typename TYPE>
87 template<
typename TYPE>
91 template<
typename TYPE,
typename Callback>
96 template<
typename TYPE>
99 template<
typename TYPE,
typename Callback>
103 template<
typename TYPE,
typename Callback>
108 template<
typename TYPE,
typename Callback>
111 const Callback& compares);
113 template<
typename TYPE,
typename Callback>
116 const Callback& compares);
119 template<
typename TYPE,
typename Callback>
130 template <
typename TYPE>
133 return distance(*end, *begin);
136 template<
typename TYPE>
138 return frontOf(*it, steps);
141 template<
typename TYPE>
142 static auto backOf(
const iterator<TYPE> *it, int64_t steps) -> iterator<TYPE> * {
143 return backOf(*it, steps);
146 template<
typename TYPE,
typename Callback>
147 requires original::Condition<Callback, TYPE>
148 static auto allOf(
const iterator<TYPE> *begin,
const iterator<TYPE> *end,
149 const Callback &condition) ->
bool {
150 return allOf(*begin, *end, condition);
153 template<
typename TYPE,
typename Callback>
154 requires original::Condition<Callback, TYPE>
155 static auto anyOf(
const iterator<TYPE> *begin,
const iterator<TYPE> *end,
156 const Callback &condition) ->
bool {
157 return anyOf(*begin, *end, condition);
160 template<
typename TYPE,
typename Callback>
161 requires original::Condition<Callback, TYPE>
162 static auto noneOf(
const iterator<TYPE> *begin,
const iterator<TYPE> *end,
163 const Callback &condition) ->
bool {
164 return noneOf(*begin, *end, condition);
167 template <
typename TYPE>
168 static auto find(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
169 const TYPE& target) -> iterator<TYPE>* {
170 return find(*begin, *end, target);
173 template <
typename TYPE>
174 static auto find(
const iterator<TYPE>* begin, uint32_t n,
175 const TYPE& target) -> iterator<TYPE>* {
176 return find(*begin, n, target);
179 template<
typename TYPE,
typename Callback>
180 requires original::Condition<Callback, TYPE>
181 static auto find(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
182 const Callback& condition) -> iterator<TYPE>* {
183 return find(*begin, *end, condition);
186 template <
typename TYPE,
typename Callback>
187 requires original::Condition<Callback, TYPE>
188 static auto find(
const iterator<TYPE>* begin, uint32_t n,
const Callback& condition) -> iterator<TYPE>* {
189 return find(*begin, n, condition);
192 template <
typename TYPE>
193 static auto count(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
194 const TYPE& target) -> uint32_t {
195 return count(*begin, *end, target);
198 template <
typename TYPE,
typename Callback>
199 requires original::Condition<Callback, TYPE>
200 static auto count(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
201 const Callback& condition) -> uint32_t {
202 return count(*begin, *end, condition);
205 template <
typename TYPE>
206 static auto equal(
const iterator<TYPE>* begin1,
const iterator<TYPE>* end1,
207 const iterator<TYPE>* begin2,
const iterator<TYPE>* end2) ->
bool {
208 return equal(*begin1, *end1, *begin2, *end2);
211 template <
typename TYPE,
typename Callback>
212 requires original::Operation<Callback, TYPE>
213 static auto forEach(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
214 Callback operation) ->
void {
215 forEach(*begin, *end, operation);
218 template <
typename TYPE,
typename Callback>
219 requires original::Operation<Callback, TYPE>
220 static auto forEach(
const iterator<TYPE>* begin, uint32_t n, Callback operation) -> iterator<TYPE>* {
221 return forEach(*begin, n, operation);
224 template<
typename TYPE>
225 static auto fill(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
226 const TYPE& value) ->
void {
227 fill(*begin, *end, value);
230 template<
typename TYPE>
231 static auto fill(
const iterator<TYPE>* begin, uint32_t n,
const TYPE& value) -> iterator<TYPE>* {
232 return fill(*begin, n, value);
235 template <
typename TYPE>
236 static auto swap(
const iterator<TYPE>* it1,
const iterator<TYPE>* it2)
noexcept ->
void {
240 template <
typename TYPE>
241 static auto copy(
const iterator<TYPE>* begin_src,
const iterator<TYPE>* end_src,
242 const iterator<TYPE>* begin_tar) -> iterator<TYPE>* {
243 return copy(*begin_src, *end_src, *begin_tar);
246 template<
typename TYPE,
typename Callback>
247 requires original::Condition<Callback, TYPE>
248 static auto copy(
const iterator<TYPE>* begin_src,
const iterator<TYPE>* end_src,
249 const iterator<TYPE>* begin_tar, Callback condition) -> iterator<TYPE>* {
250 return copy(*begin_src, *end_src, *begin_tar, condition);
253 template<
typename TYPE>
254 static auto reverse(
const iterator<TYPE>* begin,
const iterator<TYPE>* end) -> iterator<TYPE>* {
255 return reverse(*begin, *end);
258 template <
typename TYPE,
typename Callback>
259 requires original::Compare<Callback, TYPE>
260 static auto compare(
const iterator<TYPE>* it1,
const iterator<TYPE>* it2,
261 const Callback& compares) ->
bool {
262 return compare(*it1, *it2, compares);
265 template<
typename TYPE,
typename Callback>
266 requires original::Compare<Callback, TYPE>
267 static auto heapAdjustDown(
const iterator<TYPE>* begin,
const iterator<TYPE>* range,
268 const iterator<TYPE>* current,
const Callback& compares) ->
void {
269 heapAdjustDown(*begin, *range, *current, compares);
272 template<
typename TYPE,
typename Callback>
273 requires original::Compare<Callback, TYPE>
274 static auto heapAdjustUp(
const iterator<TYPE>* begin,
const iterator<TYPE>* current,
275 const Callback& compares) ->
void {
276 heapAdjustUp(*begin, *current, compares);
279 template<
typename TYPE,
typename Callback>
280 requires original::Compare<Callback, TYPE>
281 static auto heapInit(
const iterator<TYPE>* begin,
const iterator<TYPE>* end,
282 const Callback& compares) ->
void {
283 heapInit(*begin, *end, compares);
286 template<
typename TYPE,
typename Callback>
287 requires original::Compare<Callback, TYPE>
288 static auto heapGetPrior(
const iterator<TYPE>* begin,
const iterator<TYPE>* range,
289 const iterator<TYPE>* parent,
const Callback& compares) -> iterator<TYPE>* {
290 return heapGetPrior(*begin, *range, *parent, compares);
295 template <
typename TYPE>
296 auto original::algorithms::distance(
const iterator<TYPE>& end,
const iterator<TYPE>& begin) -> int64_t
298 auto* it1 = end.clone();
299 auto* it2 = begin.clone();
300 auto dis = it1->operator-(*it2);
306 template<
typename TYPE>
311 template<
typename TYPE>
312 original::iterator<TYPE> *original::algorithms::backOf(
const iterator<TYPE> &it, int64_t steps) {
316 template<
typename TYPE,
typename Callback>
317 requires original::Condition<Callback, TYPE>
319 const Callback& condition) {
320 auto* it = begin.clone();
321 for (; distance(*it, end) <= 0; it->next()){
322 if (!condition(it->get())){
331 template<
typename TYPE,
typename Callback>
332 requires original::Condition<Callback, TYPE>
334 const Callback& condition) {
335 auto* it = begin.clone();
336 for (; distance(*it, end) <= 0; it->next()){
337 if (condition(it->get())){
346 template<
typename TYPE,
typename Callback>
347 requires original::Condition<Callback, TYPE>
349 const Callback& condition) {
350 auto* it = begin.clone();
351 for (; distance(*it, end) <= 0; it->next()){
352 if (condition(it->get())){
361 template <
typename TYPE>
364 auto it = begin.clone();
365 while (it->isValid() && !it->equal(end)) {
366 if (it->get() == target) {
375 template <
typename TYPE>
377 auto it = begin.clone();
378 for (uint32_t i = 0; i < n; i += 1, it->next())
380 if (it->get() == target)
return it;
385 template<
typename TYPE,
typename Callback>
386 requires original::Condition<Callback, TYPE>
389 auto it = begin.clone();
390 while (it->isValid() && !it->equal(end)) {
391 if (condition(it->get())) {
400 template <
typename TYPE,
typename Callback>
401 requires original::Condition<Callback, TYPE>
403 auto it = begin.clone();
404 for (uint32_t i = 0; i < n; i += 1, it->next())
406 if (condition(it->get()))
return it;
411 template <
typename TYPE>
413 const TYPE& target) -> uint32_t
416 auto it = begin.clone();
417 while (it->isValid() && !end.atPrev(it)) {
418 if (it->get() == target) {
427 template <
typename TYPE,
typename Callback>
428 requires original::Condition<Callback, TYPE>
430 const Callback& condition) -> uint32_t
433 auto it = begin.clone();
434 while (it->isValid() && !end.atPrev(it)) {
435 if (condition(it->get())) {
444 template <
typename TYPE>
448 auto it1 = begin1.clone();
449 auto it2 = begin2.clone();
451 while (it1->isValid() && it2->isValid() && !it1->equal(end1) && !it2->equal(end2)) {
455 const bool res = it1->equal(end1) && it2->equal(end2) && it1->get() == it2->get();
461 template <
typename TYPE,
typename Callback>
462 requires original::Operation<Callback, TYPE>
464 Callback operation) ->
void
466 auto it = begin.clone();
467 for (; !it->equal(end); it->next()) {
468 operation(it->get());
470 operation(it->get());
474 template <
typename TYPE,
typename Callback>
475 requires original::Operation<Callback, TYPE>
476 auto original::algorithms::forEach(
const iterator<TYPE>& begin,
const uint32_t n,
478 auto it = begin.clone();
479 for (uint32_t i = 0; i < n; i += 1, it->next())
481 operation(it->get());
486 template<
typename TYPE,
typename Callback_O,
typename Callback_C>
487 requires original::Operation<Callback_O, TYPE> && original::Condition<Callback_C, TYPE>
489 const Callback_C &condition) ->
void {
490 auto it = begin.clone();
491 for (; !it->equal(end); it->next()) {
492 if (condition(it->get()))
493 operation(it->get());
495 operation(it->get());
499 template<
typename TYPE,
typename Callback_O,
typename Callback_C>
500 requires original::Operation<Callback_O, TYPE> && original::Condition<Callback_C, TYPE>
501 auto original::algorithms::forEach(
const iterator<TYPE> &begin,
const uint32_t n, Callback_O operation,
503 auto it = begin.clone();
504 for (uint32_t i = 0; i < n; i += 1, it->next())
506 if (condition(it->get()))
507 operation(it->get());
512 template<
typename TYPE>
516 auto it = begin.clone();
517 while (!it->equal(end)){
525 template<
typename TYPE>
528 auto it = begin.clone();
529 for (uint32_t i = 0; i < n; ++i) {
536 template <
typename TYPE>
539 auto it_1 = it1.clone();
540 auto it_2 = it2.clone();
541 TYPE tmp = it_2->get();
542 it_2->set(it_1->get());
548 template <
typename TYPE>
551 auto it_src = begin_src.clone();
552 auto it_tar = begin_tar.clone();
553 while (!it_src->equal(end_src)){
554 it_tar->set(it_src->get());
558 it_tar->set(it_src->get());
564 template<
typename TYPE,
typename Callback>
565 requires original::Condition<Callback, TYPE>
568 auto it_src = begin_src.clone();
569 auto it_tar = begin_tar.clone();
570 while (!it_src->equal(end_src)){
571 if (condition(it_src->get())){
572 it_tar->set(it_src->get());
577 if (condition(it_src->get())){
578 it_tar->set(it_src->get());
585 template<
typename TYPE>
588 auto left = begin.clone();
589 auto right = end.clone();
590 while (!left->equal(right) && !left->atNext(right)){
599 template <
typename TYPE,
typename Callback>
600 requires original::Compare<Callback, TYPE>
602 const Callback& compares) ->
bool
604 return compares(it1.get(), it2.get());
607 template <
typename TYPE,
typename Callback>
608 requires original::Compare<Callback, TYPE>
612 if (distance(current, begin) < 0)
615 auto* it = current.clone();
616 while (distance(*it, begin) * 2 + 1 <= distance(range, begin))
618 auto* child = heapGetPrior(begin, range, *it, compares);
619 if (compare(it, child, compares))
632 template <
typename TYPE,
typename Callback>
633 requires original::Compare<Callback, TYPE>
635 const Callback& compares) ->
void
637 auto* it = current.clone();
638 while (distance(*it, begin) > 0)
640 auto* parent = frontOf(begin, (distance(*it, begin) - 1) / 2);
641 if (compare(it, parent, compares))
654 template <
typename TYPE,
typename Callback>
655 requires original::Compare<Callback, TYPE>
657 const Callback& compares) ->
void
659 auto* it = frontOf(begin, (distance(end, begin) + 1) / 2 - 1);
660 for (; distance(*it, begin) >= 0; it->prev())
662 heapAdjustDown(begin, end, *it, compares);
667 template <
typename TYPE,
typename Callback>
668 requires original::Compare<Callback, TYPE>
672 if (distance(parent, begin) * 2 + 2 <= distance(range, begin))
674 auto* left = frontOf(begin, distance(parent, begin) * 2 + 1);
675 auto* right = frontOf(begin, distance(parent, begin) * 2 + 2);
676 if (compare(left, right, compares))
684 return frontOf(begin, distance(parent, begin) * 2 + 1);
Definition algorithms.h:11
static auto distance(const iterator< TYPE > *end, const iterator< TYPE > *begin) -> int64_t
Definition algorithms.h:131