Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TwoLevelIterator.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
20 #ifndef GALOIS_TWO_LEVEL_ITER_H
21 #define GALOIS_TWO_LEVEL_ITER_H
22 
23 #include <cassert>
24 #include <cstdlib>
25 #include <functional>
26 #include <iterator>
27 #include <type_traits>
28 
29 #include <cstdlib>
30 #include <cassert>
31 
32 #include "galois/config.h"
33 
34 namespace galois {
35 
36 namespace internal {
37 template <typename Iter>
38 void safe_decrement(Iter& it, const Iter& beg,
39  const Iter& GALOIS_USED_ONLY_IN_DEBUG(end),
40  std::forward_iterator_tag) {
41 
42  Iter next = beg;
43  Iter curr(next);
44 
45  while (next != it) {
46  curr = next;
47  assert(next != end);
48  ++next;
49  }
50 
51  assert(next == it);
52  assert(curr != it);
53 
54  it = curr;
55 }
56 
57 template <typename Iter>
58 void safe_decrement(Iter& it, const Iter& GALOIS_USED_ONLY_IN_DEBUG(beg),
59  const Iter&, std::bidirectional_iterator_tag) {
60  assert(it != beg);
61  --it;
62 }
63 
64 template <typename Iter>
65 void safe_decrement(Iter& it, const Iter& beg, const Iter& end) {
66  safe_decrement(it, beg, end,
67  typename std::iterator_traits<Iter>::iterator_category());
68 }
69 } // namespace internal
70 
72 template <typename Outer, typename Inner, typename InnerBegFn,
73  typename InnerEndFn>
75 
76 protected:
77  // TODO: make begin and end const
78  Outer m_beg_outer;
79  Outer m_end_outer;
80  Outer m_outer;
81 
82  Inner m_beg_inner;
83  Inner m_end_inner;
84  Inner m_inner;
85 
86  InnerBegFn innerBegFn;
87  InnerEndFn innerEndFn;
88 
89  inline bool outerAtBegin() const { return m_outer == m_beg_outer; }
90 
91  inline bool outerAtEnd() const { return m_outer == m_end_outer; }
92 
93  inline bool outerEmpty() const { return m_beg_outer == m_end_outer; }
94 
95  inline const Inner& getInnerBegin() const { return m_beg_inner; }
96 
97  inline const Inner& getInnerEnd() const { return m_end_inner; }
98 
99  inline void setInnerAtBegin(void) {
100  assert(!outerAtEnd());
103  }
104 
105  inline void setInnerAtEnd(void) {
106  assert(!outerAtEnd());
109  }
110 
111  inline bool innerAtBegin() const {
112  assert(m_beg_inner == innerBegFn(*m_outer));
113  return m_inner == m_beg_inner;
114  }
115 
116  inline bool innerAtEnd() const {
117  assert(m_end_inner == innerEndFn(*m_outer));
118  return m_inner == m_end_inner;
119  }
120 
123  m_inner(), innerBegFn(), innerEndFn() {}
124 
125  TwoLevelIterBase(Outer beg_outer, Outer end_outer, Outer outer_pos,
126  InnerBegFn innerBegFn, InnerEndFn innerEndFn)
127  : m_beg_outer(beg_outer), m_end_outer(end_outer), m_outer(outer_pos),
128  m_beg_inner(), m_end_inner(), m_inner(), innerBegFn(innerBegFn),
129  innerEndFn(innerEndFn) {}
130 };
131 
133 template <typename Outer, typename Inner, typename InnerBegFn,
134  typename InnerEndFn>
136  : public std::iterator_traits<Inner>,
137  public TwoLevelIterBase<Outer, Inner, InnerBegFn, InnerEndFn> {
138 
139 protected:
140  typedef std::iterator_traits<Inner> Traits;
142 
143  void nextOuter() {
144  assert(!Base::outerAtEnd());
145  assert(!Base::outerEmpty());
146  ++Base::m_outer;
147  if (!Base::outerAtEnd()) {
148 
150  // Base::m_inner = Base::innerBegin ();
151  }
152  }
153 
154  void seekValidBegin() {
155  while (!Base::outerAtEnd() && Base::innerAtEnd()) {
156  nextOuter();
157  }
158  }
159 
160  void step_forward() {
161  assert(!Base::innerAtEnd());
162  ++Base::m_inner;
163 
164  if (Base::innerAtEnd()) {
165  seekValidBegin();
166  }
167  }
168 
169  bool is_equal(const TwoLevelFwdIter& that) const {
170  // the outer iterators of 'this' and 'that' have been initialized
171  // with either (beg,end), or, (end, end)
172  // - for two level begin, outer is initialized to (beg,end)
173  // - for two level end, outer is initialized to (end, end)
174  assert(this->m_end_outer == that.m_end_outer);
175 
176  return (this->m_outer == that.m_outer) &&
177  (Base::outerAtEnd() || (this->m_inner == that.m_inner));
178  }
179 
180 public:
182 
183  TwoLevelFwdIter(Outer beg_outer, Outer end_outer, Outer outer_pos,
184  InnerBegFn innerBegFn, InnerEndFn innerEndFn)
185  : Base(beg_outer, end_outer, outer_pos, innerBegFn, innerEndFn) {
186 
187  if (!Base::outerAtEnd()) {
188  // Base::m_inner = Base::innerBegin ();
190  seekValidBegin();
191  }
192  }
193 
194  typename Traits::reference operator*() const { return *Base::m_inner; }
195 
196  typename Traits::pointer operator->() const {
197  return Base::m_inner->operator->();
198  }
199 
201  step_forward();
202  return *this;
203  }
204 
206  TwoLevelFwdIter tmp(*this);
207  step_forward();
208  return tmp;
209  }
210 
211  friend bool operator==(const TwoLevelFwdIter& left,
212  const TwoLevelFwdIter& right) {
213  return left.is_equal(right);
214  }
215 
216  friend bool operator!=(const TwoLevelFwdIter& left,
217  const TwoLevelFwdIter& right) {
218  return !left.is_equal(right);
219  }
220 };
221 
223 template <typename Outer, typename Inner, typename InnerBegFn,
224  typename InnerEndFn>
226  : public TwoLevelFwdIter<Outer, Inner, InnerBegFn, InnerEndFn> {
227 
228 protected:
230 
231 protected:
232  void prevOuter() {
233  assert(!FwdBase::outerAtBegin());
234  assert(!FwdBase::outerEmpty());
235 
236  internal::safe_decrement(FwdBase::m_outer, FwdBase::m_beg_outer,
238 
239  // FwdBase::m_inner = FwdBase::innerEnd ();
241  }
242 
243  void step_backward() {
244  assert(!FwdBase::outerEmpty());
245 
246  // assert (!FwdBase::outerAtBegin ());
247 
248  // calling innerBegin when m_outer == m_end_outer is invalid
249  // so call prevOuter first, and check for innerBegin afterwards
250 
251  if (FwdBase::outerAtEnd()) {
252  prevOuter();
253  }
254 
255  while (FwdBase::innerAtBegin()) {
256  assert(!FwdBase::outerAtBegin());
257  prevOuter();
258  }
259 
260  assert(FwdBase::innerAtBegin() ? FwdBase::outerAtBegin() : true);
261 
263  }
264 
265 public:
267 
268  TwoLevelBiDirIter(Outer beg_outer, Outer end_outer, Outer outer_pos,
269  InnerBegFn innerBegFn, InnerEndFn innerEndFn)
270  : FwdBase(beg_outer, end_outer, outer_pos, innerBegFn, innerEndFn) {}
271 
273  step_backward();
274  return *this;
275  }
276 
278  TwoLevelBiDirIter tmp(*this);
279  step_backward();
280  return tmp;
281  }
282 };
283 
285 template <typename Outer, typename Inner, typename InnerBegFn,
286  typename InnerEndFn>
288  : public TwoLevelBiDirIter<Outer, Inner, InnerBegFn, InnerEndFn> {
289 
290 protected:
292 
293  typedef typename BiDirBase::Traits::difference_type Diff_ty;
294 
295  void jump_forward(const Diff_ty d) {
296  assert(!BiDirBase::outerEmpty());
297 
298  if (d < 0) {
299  jump_backward(-d);
300 
301  } else {
302  Diff_ty rem(d);
303 
304  while (rem > 0) {
305  assert(!BiDirBase::outerAtEnd());
306 
307  Diff_ty avail =
308  std::distance(BiDirBase::m_inner, BiDirBase::getInnerEnd());
309  assert(avail >= 0);
310 
311  if (rem > avail) {
312  rem -= avail;
313  assert(!BiDirBase::outerAtEnd());
315 
316  } else {
317  BiDirBase::m_inner += rem;
318  rem = 0;
319  }
320 
322  }
323  }
324  }
325 
326  void jump_backward(const Diff_ty d) {
327  assert(!BiDirBase::outerEmpty());
328 
329  if (d < 0) {
330  jump_forward(-d);
331 
332  } else {
333 
334  Diff_ty rem(d);
335 
336  if ((rem > 0) && BiDirBase::outerAtEnd()) {
338  }
339 
340  while (rem > 0) {
341  Diff_ty avail =
343  assert(avail >= 0);
344 
345  if (rem > avail) {
346  rem -= avail;
347  assert(!BiDirBase::outerAtBegin());
349 
350  } else {
351 
352  BiDirBase::m_inner -= rem;
353  rem = 0;
354  break;
355  }
356  }
357  }
358  }
359 
360  Diff_ty compute_dist(const TwoLevelRandIter& that) const {
361 
362  if (std::distance(this->m_outer, that.m_outer) <
363  0) { // this->m_outer > that.m_outer
364  return -(that.compute_dist(*this));
365 
366  } else if (this->m_outer == that.m_outer) {
367  if (!BiDirBase::outerAtEnd()) {
368  return std::distance(this->m_inner, that.m_inner);
369 
370  } else {
371  return 0;
372  }
373 
374  } else {
375 
376  assert(std::distance(this->m_outer, that.m_outer) >
377  0); // this->m_outer < that.m_outer;
378  assert(!BiDirBase::outerAtEnd());
379 
380  TwoLevelRandIter tmp(*this);
381 
382  Diff_ty d = tmp.m_inner - tmp.m_inner; // 0
383 
384  while (tmp.m_outer != that.m_outer) {
385  d += std::distance(tmp.m_inner, tmp.getInnerEnd());
386  tmp.nextOuter();
387  }
388 
389  assert(tmp.m_outer == that.m_outer);
390 
391  if (tmp.m_outer != tmp.m_end_outer) {
392  d += std::distance(tmp.m_inner, that.m_inner);
393  }
394 
395  assert(d >= 0);
396 
397  return d;
398  }
399  }
400 
401 public:
403 
404  TwoLevelRandIter(Outer beg_outer, Outer end_outer, Outer outer_pos,
405  InnerBegFn innerBegFn, InnerEndFn innerEndFn)
406  : BiDirBase(beg_outer, end_outer, outer_pos, innerBegFn, innerEndFn) {}
407 
409  jump_forward(d);
410  return *this;
411  }
412 
414  jump_backward(d);
415  return *this;
416  }
417 
419  TwoLevelRandIter tmp(it);
420  tmp += d;
421  return tmp;
422  }
423 
425  return (it + d);
426  }
427 
429  TwoLevelRandIter tmp(it);
430  tmp -= d;
431  return tmp;
432  }
433 
434  friend Diff_ty operator-(const TwoLevelRandIter& left,
435  const TwoLevelRandIter& right) {
436 
437  return right.compute_dist(left);
438  }
439 
440  typename BiDirBase::Traits::reference operator[](Diff_ty d) const {
441  return *((*this) + d);
442  }
443 
444  friend bool operator<(const TwoLevelRandIter& left,
445  const TwoLevelRandIter& right) {
446  return ((left.m_outer == right.m_outer) ? (left.m_inner < right.m_inner)
447  : (left.m_outer < right.m_outer));
448  }
449 
450  friend bool operator<=(const TwoLevelRandIter& left,
451  const TwoLevelRandIter& right) {
452  return (left < right) || (left == right);
453  }
454 
455  friend bool operator>(const TwoLevelRandIter& left,
456  const TwoLevelRandIter& right) {
457  return !(left <= right);
458  }
459 
460  friend bool operator>=(const TwoLevelRandIter& left,
461  const TwoLevelRandIter& right) {
462  return !(left < right);
463  }
464 };
465 
466 namespace internal {
467 
468 template <typename Outer, typename Inner, typename InnerBegFn,
469  typename InnerEndFn, typename Cat>
470 struct ByCategory {};
471 
472 template <typename Outer, typename Inner, typename InnerBegFn,
473  typename InnerEndFn>
474 struct ByCategory<Outer, Inner, InnerBegFn, InnerEndFn,
475  std::forward_iterator_tag> {
476  typedef TwoLevelFwdIter<Outer, Inner, InnerBegFn, InnerEndFn> type;
477 };
478 
479 template <typename Outer, typename Inner, typename InnerBegFn,
480  typename InnerEndFn>
481 struct ByCategory<Outer, Inner, InnerBegFn, InnerEndFn,
482  std::bidirectional_iterator_tag> {
483  typedef TwoLevelBiDirIter<Outer, Inner, InnerBegFn, InnerEndFn> type;
484 };
485 
486 template <typename Outer, typename Inner, typename InnerBegFn,
487  typename InnerEndFn>
488 struct ByCategory<Outer, Inner, InnerBegFn, InnerEndFn,
489  std::random_access_iterator_tag> {
490  typedef TwoLevelRandIter<Outer, Inner, InnerBegFn, InnerEndFn> type;
491 };
492 
493 // template <typename Outer, typename Inner>
494 // struct IsRvrsIter {
495 //
496 // template <typename O, typename I>
497 // struct IsRev {
498 // static const bool VAL = false;
499 // };
500 //
501 // template <typename O>
502 // struct IsRev<O, typename O::value_type::reverse_iterator> {
503 // static const bool VAL = true;
504 // };
505 //
506 // template <typename O, typename I>
507 // struct IsConstRev {
508 // static const bool VAL = false;
509 // };
510 //
511 // template <typename O>
512 // struct IsConstRev<O, typename O::value_type::const_reverse_iterator> {
513 // static const bool VAL = true;
514 // };
515 //
516 //
517 // static const bool VAL =
518 // IsRev<Outer, Inner>::VAL || IsConstRev<Outer, Inner>::VAL;
519 // };
520 
521 } // namespace internal
522 
524 template <typename Outer, typename Inner, typename InnerBegFn,
525  typename InnerEndFn>
527 private:
528  // typedef typename std::iterator_traits<Outer>::iterator_category CatOuter;
529  typedef typename std::iterator_traits<Inner>::iterator_category CatInner;
530 
531 public:
532  typedef typename internal::ByCategory<Outer, Inner, InnerBegFn, InnerEndFn,
533  CatInner>::type type;
534 };
535 
537 template <typename Outer, typename InnerBegFn, typename InnerEndFn>
538 typename ChooseTwoLevelIterator<Outer, typename InnerBegFn::result_type,
539  InnerBegFn, InnerEndFn>::type
540 make_two_level_begin(Outer beg, Outer end, InnerBegFn innerBegFn,
541  InnerEndFn innerEndFn) {
542 #ifndef NDEBUG
543  const bool V = std::is_same<typename InnerBegFn::result_type,
544  typename InnerEndFn::result_type>::value;
545  assert(V);
546 #endif
547 
548  typedef typename InnerBegFn::result_type Inner;
549  typedef typename ChooseTwoLevelIterator<Outer, Inner, InnerBegFn,
550  InnerEndFn>::type Ret_ty;
551 
552  return Ret_ty(beg, end, beg, innerBegFn, innerEndFn);
553 }
554 
556 template <typename Outer, typename InnerBegFn, typename InnerEndFn>
557 typename ChooseTwoLevelIterator<Outer, typename InnerBegFn::result_type,
558  InnerBegFn, InnerEndFn>::type
559 make_two_level_end(Outer beg, Outer end, InnerBegFn innerBegFn,
560  InnerEndFn innerEndFn) {
561  // const bool V = std::is_same<typename InnerBegFn::result_type, typename
562  // InnerEndFn::result_type>::value; static_assert (V);
563 
564  typedef typename InnerBegFn::result_type Inner;
565  typedef typename ChooseTwoLevelIterator<Outer, Inner, InnerBegFn,
566  InnerEndFn>::type Ret_ty;
567 
568  return Ret_ty(beg, end, end, innerBegFn, innerEndFn);
569 }
570 
571 namespace internal {
572 template <typename C>
573 struct GetBegin : public std::unary_function<C&, typename C::iterator> {
574  inline typename C::iterator operator()(C& c) const { return c.begin(); }
575 };
576 
577 template <typename C>
578 struct GetEnd : public std::unary_function<C&, typename C::iterator> {
579  inline typename C::iterator operator()(C& c) const { return c.end(); }
580 };
581 
582 // TODO: update to c++11 names
583 template <typename C>
584 struct GetCbegin
585  : public std::unary_function<const C&, typename C::const_iterator> {
586  inline typename C::const_iterator operator()(const C& c) const {
587  return c.begin();
588  }
589 };
590 
591 template <typename C>
592 struct GetCend
593  : public std::unary_function<const C&, typename C::const_iterator> {
594  inline typename C::const_iterator operator()(const C& c) const {
595  return c.end();
596  }
597 };
598 
599 template <typename C>
600 struct GetRbegin
601  : public std::unary_function<C&, typename C::reverse_iterator> {
602  inline typename C::reverse_iterator operator()(C& c) const {
603  return c.rbegin();
604  }
605 };
606 
607 template <typename C>
608 struct GetRend : public std::unary_function<C&, typename C::reverse_iterator> {
609  inline typename C::reverse_iterator operator()(C& c) const {
610  return c.rend();
611  }
612 };
613 
614 // TODO: update to c++11 names
615 template <typename C>
616 struct GetCRbegin
617  : public std::unary_function<const C&, typename C::const_reverse_iterator> {
618  inline typename C::const_reverse_iterator operator()(const C& c) const {
619  return c.rbegin();
620  }
621 };
622 
623 template <typename C>
624 struct GetCRend
625  : public std::unary_function<const C&, typename C::const_reverse_iterator> {
626  inline typename C::const_reverse_iterator operator()(const C& c) const {
627  return c.rend();
628  }
629 };
630 
631 enum StlIterKind { NORMAL, _CONST, REVERSE, _CONST_REVERSE };
632 
633 template <typename C, typename I>
634 struct IsConstIter {
635  static const bool value = false;
636 };
637 
638 template <typename C>
639 struct IsConstIter<C, typename C::const_iterator> {
640  static const bool value = true;
641 };
642 
643 template <typename C, typename I>
644 struct IsRvrsIter {
645  static const bool value = false;
646 };
647 
648 template <typename C>
649 struct IsRvrsIter<C, typename C::reverse_iterator> {
650  static const bool value = true;
651 };
652 
653 template <typename C, typename I>
654 struct IsRvrsConstIter {
655  static const bool value = false;
656 };
657 
658 template <typename C>
659 struct IsRvrsConstIter<C, typename C::const_reverse_iterator> {
660  static const bool value = true;
661 };
662 
663 template <typename C, typename I>
664 struct GetStlIterKind {
665  static const bool isRvrs =
666  IsRvrsIter<C, I>::value || IsRvrsConstIter<C, I>::value;
667  static const bool isConst =
668  IsConstIter<C, I>::value || IsRvrsConstIter<C, I>::value;
669 
670  static const StlIterKind value = isRvrs ? (isConst ? _CONST_REVERSE : REVERSE)
671  : (isConst ? _CONST : NORMAL);
672 };
673 
674 template <typename C, typename I, enum StlIterKind>
675 struct ChooseStlIter {
676  typedef void Inner;
677 };
678 
679 template <typename C, typename I>
680 struct ChooseStlIter<C, I, NORMAL> {
681 
682  typedef typename C::iterator Inner;
683  typedef GetBegin<C> InnerBegFn;
684  typedef GetEnd<C> InnerEndFn;
685 };
686 
687 template <typename C, typename I>
688 struct ChooseStlIter<C, I, _CONST> {
689 
690  typedef typename C::const_iterator Inner;
691  typedef GetCbegin<C> InnerBegFn;
692  typedef GetCend<C> InnerEndFn;
693 };
694 
695 template <typename C, typename I>
696 struct ChooseStlIter<C, I, REVERSE> {
697 
698  typedef typename C::reverse_iterator Inner;
699  typedef GetRbegin<C> InnerBegFn;
700  typedef GetRend<C> InnerEndFn;
701 };
702 
703 template <typename C, typename I>
704 struct ChooseStlIter<C, I, _CONST_REVERSE> {
705 
706  typedef typename C::const_reverse_iterator Inner;
707  typedef GetCRbegin<C> InnerBegFn;
708  typedef GetCRend<C> InnerEndFn;
709 };
710 
711 template <typename Outer, typename Inner>
712 struct ChooseStlTwoLevelIterImpl {
713 
714  typedef typename std::iterator_traits<Outer>::value_type C;
715  static const internal::StlIterKind KIND =
716  internal::GetStlIterKind<C, Inner>::value;
717  typedef internal::ChooseStlIter<C, Inner, KIND> CStl;
718  typedef typename CStl::InnerBegFn InnerBegFn;
719  typedef typename CStl::InnerEndFn InnerEndFn;
720  typedef typename ChooseTwoLevelIterator<Outer, Inner, InnerBegFn,
721  InnerEndFn>::type type;
722 
723  static type make(Outer beg, Outer end, Outer outer_pos) {
724  return type(beg, end, outer_pos, InnerBegFn(), InnerEndFn());
725  }
726 };
727 
728 template <typename Outer>
729 struct StlInnerIsIterator
730  : public ChooseStlTwoLevelIterImpl<
731  Outer, typename std::iterator_traits<Outer>::value_type::iterator> {};
732 
733 template <typename Outer>
734 struct StlInnerIsConstIterator
735  : public ChooseStlTwoLevelIterImpl<
736  Outer,
737  typename std::iterator_traits<Outer>::value_type::const_iterator> {};
738 
739 template <typename Outer>
740 struct StlInnerIsRvrsIterator
741  : public ChooseStlTwoLevelIterImpl<
742  Outer,
743  typename std::iterator_traits<Outer>::value_type::reverse_iterator> {
744 };
745 
746 template <typename Outer>
747 struct StlInnerIsConstRvrsIterator
748  : public ChooseStlTwoLevelIterImpl<
749  Outer, typename std::iterator_traits<
750  Outer>::value_type::const_reverse_iterator> {};
751 
752 } // namespace internal
753 
755 template <typename Outer, typename Inner>
757  typedef typename internal::ChooseStlTwoLevelIterImpl<Outer, Inner>::type type;
758 };
759 
760 template <typename Outer>
761 typename internal::StlInnerIsIterator<Outer>::type
762 stl_two_level_begin(Outer beg, Outer end) {
763  return internal::StlInnerIsIterator<Outer>::make(beg, end, beg);
764 }
765 
766 template <typename Outer>
767 typename internal::StlInnerIsIterator<Outer>::type
768 stl_two_level_end(Outer beg, Outer end) {
769  return internal::StlInnerIsIterator<Outer>::make(beg, end, end);
770 }
771 
772 template <typename Outer>
773 typename internal::StlInnerIsConstIterator<Outer>::type
774 stl_two_level_cbegin(Outer beg, Outer end) {
775  return internal::StlInnerIsConstIterator<Outer>::make(beg, end, beg);
776 }
777 
778 template <typename Outer>
779 typename internal::StlInnerIsConstIterator<Outer>::type
780 stl_two_level_cend(Outer beg, Outer end) {
781  return internal::StlInnerIsConstIterator<Outer>::make(beg, end, end);
782 }
783 
784 template <typename Outer>
785 typename internal::StlInnerIsRvrsIterator<Outer>::type
786 stl_two_level_rbegin(Outer beg, Outer end) {
787  return internal::StlInnerIsRvrsIterator<Outer>::make(beg, end, beg);
788 }
789 
790 template <typename Outer>
791 typename internal::StlInnerIsRvrsIterator<Outer>::type
792 stl_two_level_rend(Outer beg, Outer end) {
793  return internal::StlInnerIsRvrsIterator<Outer>::make(beg, end, end);
794 }
795 
796 template <typename Outer>
797 typename internal::StlInnerIsConstRvrsIterator<Outer>::type
798 stl_two_level_crbegin(Outer beg, Outer end) {
799  return internal::StlInnerIsConstRvrsIterator<Outer>::make(beg, end, beg);
800 }
801 
802 template <typename Outer>
803 typename internal::StlInnerIsConstRvrsIterator<Outer>::type
804 stl_two_level_crend(Outer beg, Outer end) {
805  return internal::StlInnerIsConstRvrsIterator<Outer>::make(beg, end, end);
806 }
807 
808 } // end namespace galois
809 
810 #endif // GALOIS_TWO_LEVEL_ITER_H
TwoLevelIterBase()
Definition: TwoLevelIterator.h:121
BiDirBase::Traits::reference operator[](Diff_ty d) const
Definition: TwoLevelIterator.h:440
Two-Level forward iterator.
Definition: TwoLevelIterator.h:135
Outer m_outer
Definition: TwoLevelIterator.h:80
friend bool operator<(const TwoLevelRandIter &left, const TwoLevelRandIter &right)
Definition: TwoLevelIterator.h:444
internal::StlInnerIsConstIterator< Outer >::type stl_two_level_cend(Outer beg, Outer end)
Definition: TwoLevelIterator.h:780
Traits::reference operator*() const
Definition: TwoLevelIterator.h:194
void step_forward()
Definition: TwoLevelIterator.h:160
void seekValidBegin()
Definition: TwoLevelIterator.h:154
friend bool operator!=(const TwoLevelFwdIter &left, const TwoLevelFwdIter &right)
Definition: TwoLevelIterator.h:216
bool outerAtEnd() const
Definition: TwoLevelIterator.h:91
TwoLevelIterBase(Outer beg_outer, Outer end_outer, Outer outer_pos, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Definition: TwoLevelIterator.h:125
TwoLevelIterBase< Outer, Inner, InnerBegFn, InnerEndFn > Base
Definition: TwoLevelIterator.h:141
bool innerAtBegin() const
Definition: TwoLevelIterator.h:111
TwoLevelFwdIter()
Definition: TwoLevelIterator.h:181
const Inner & getInnerEnd() const
Definition: TwoLevelIterator.h:97
bool innerAtEnd() const
Definition: TwoLevelIterator.h:116
TwoLevelBiDirIter< Outer, Inner, InnerBegFn, InnerEndFn > BiDirBase
Definition: TwoLevelIterator.h:291
internal::StlInnerIsRvrsIterator< Outer >::type stl_two_level_rbegin(Outer beg, Outer end)
Definition: TwoLevelIterator.h:786
Type function to select appropriate two-level iterator.
Definition: TwoLevelIterator.h:526
friend bool operator==(const TwoLevelFwdIter &left, const TwoLevelFwdIter &right)
Definition: TwoLevelIterator.h:211
TwoLevelRandIter()
Definition: TwoLevelIterator.h:402
friend TwoLevelRandIter operator+(Diff_ty d, const TwoLevelRandIter &it)
Definition: TwoLevelIterator.h:424
TwoLevelRandIter(Outer beg_outer, Outer end_outer, Outer outer_pos, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Definition: TwoLevelIterator.h:404
Inner m_inner
Definition: TwoLevelIterator.h:84
ChooseTwoLevelIterator< Outer, typename InnerBegFn::result_type, InnerBegFn, InnerEndFn >::type make_two_level_end(Outer beg, Outer end, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Creates two level iterator.
Definition: TwoLevelIterator.h:559
TwoLevelFwdIter< Outer, Inner, InnerBegFn, InnerEndFn > FwdBase
Definition: TwoLevelIterator.h:229
friend TwoLevelRandIter operator-(const TwoLevelRandIter &it, Diff_ty d)
Definition: TwoLevelIterator.h:428
bool outerEmpty() const
Definition: TwoLevelIterator.h:93
TwoLevelRandIter & operator-=(Diff_ty d)
Definition: TwoLevelIterator.h:413
void jump_backward(const Diff_ty d)
Definition: TwoLevelIterator.h:326
void nextOuter()
Definition: TwoLevelIterator.h:143
Inner m_beg_inner
Definition: TwoLevelIterator.h:82
internal::StlInnerIsConstRvrsIterator< Outer >::type stl_two_level_crbegin(Outer beg, Outer end)
Definition: TwoLevelIterator.h:798
Common functionality of TwoLevelIterators.
Definition: TwoLevelIterator.h:74
Outer m_beg_outer
Definition: TwoLevelIterator.h:78
TwoLevelBiDirIter operator--(int)
Definition: TwoLevelIterator.h:277
ChooseTwoLevelIterator< Outer, typename InnerBegFn::result_type, InnerBegFn, InnerEndFn >::type make_two_level_begin(Outer beg, Outer end, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Creates two level iterator.
Definition: TwoLevelIterator.h:540
Two-Level random access iterator.
Definition: TwoLevelIterator.h:287
Outer m_end_outer
Definition: TwoLevelIterator.h:79
std::iterator_traits< Inner > Traits
Definition: TwoLevelIterator.h:140
Traits::pointer operator->() const
Definition: TwoLevelIterator.h:196
BiDirBase::Traits::difference_type Diff_ty
Definition: TwoLevelIterator.h:293
Inner m_end_inner
Definition: TwoLevelIterator.h:83
friend bool operator<=(const TwoLevelRandIter &left, const TwoLevelRandIter &right)
Definition: TwoLevelIterator.h:450
friend TwoLevelRandIter operator+(const TwoLevelRandIter &it, Diff_ty d)
Definition: TwoLevelIterator.h:418
TwoLevelFwdIter operator++(int)
Definition: TwoLevelIterator.h:205
Diff_ty compute_dist(const TwoLevelRandIter &that) const
Definition: TwoLevelIterator.h:360
bool outerAtBegin() const
Definition: TwoLevelIterator.h:89
TwoLevelFwdIter(Outer beg_outer, Outer end_outer, Outer outer_pos, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Definition: TwoLevelIterator.h:183
TwoLevelBiDirIter(Outer beg_outer, Outer end_outer, Outer outer_pos, InnerBegFn innerBegFn, InnerEndFn innerEndFn)
Definition: TwoLevelIterator.h:268
void setInnerAtBegin(void)
Definition: TwoLevelIterator.h:99
TwoLevelRandIter & operator+=(Diff_ty d)
Definition: TwoLevelIterator.h:408
TwoLevelFwdIter & operator++()
Definition: TwoLevelIterator.h:200
void operator()(void)
Definition: Executor_ParaMeter.h:417
internal::StlInnerIsConstIterator< Outer >::type stl_two_level_cbegin(Outer beg, Outer end)
Definition: TwoLevelIterator.h:774
Two-Level bidirectional iterator.
Definition: TwoLevelIterator.h:225
internal::StlInnerIsConstRvrsIterator< Outer >::type stl_two_level_crend(Outer beg, Outer end)
Definition: TwoLevelIterator.h:804
InnerBegFn innerBegFn
Definition: TwoLevelIterator.h:86
internal::ChooseStlTwoLevelIterImpl< Outer, Inner >::type type
Definition: TwoLevelIterator.h:757
internal::ByCategory< Outer, Inner, InnerBegFn, InnerEndFn, CatInner >::type type
Definition: TwoLevelIterator.h:533
TwoLevelBiDirIter()
Definition: TwoLevelIterator.h:266
TwoLevelBiDirIter & operator--()
Definition: TwoLevelIterator.h:272
bool is_equal(const TwoLevelFwdIter &that) const
Definition: TwoLevelIterator.h:169
InnerEndFn innerEndFn
Definition: TwoLevelIterator.h:87
internal::StlInnerIsIterator< Outer >::type stl_two_level_begin(Outer beg, Outer end)
Definition: TwoLevelIterator.h:762
internal::StlInnerIsIterator< Outer >::type stl_two_level_end(Outer beg, Outer end)
Definition: TwoLevelIterator.h:768
friend Diff_ty operator-(const TwoLevelRandIter &left, const TwoLevelRandIter &right)
Definition: TwoLevelIterator.h:434
void jump_forward(const Diff_ty d)
Definition: TwoLevelIterator.h:295
Type function to select appropriate two-level iterator.
Definition: TwoLevelIterator.h:756
T value_type
Definition: Executor_ParaMeter.h:111
const Inner & getInnerBegin() const
Definition: TwoLevelIterator.h:95
friend bool operator>(const TwoLevelRandIter &left, const TwoLevelRandIter &right)
Definition: TwoLevelIterator.h:455
void setInnerAtEnd(void)
Definition: TwoLevelIterator.h:105
void prevOuter()
Definition: TwoLevelIterator.h:232
void step_backward()
Definition: TwoLevelIterator.h:243
internal::StlInnerIsRvrsIterator< Outer >::type stl_two_level_rend(Outer beg, Outer end)
Definition: TwoLevelIterator.h:792
friend bool operator>=(const TwoLevelRandIter &left, const TwoLevelRandIter &right)
Definition: TwoLevelIterator.h:460