16#ifndef UTIL_GRAPH_ITERATORS_H_
17#define UTIL_GRAPH_ITERATORS_H_
23#include "absl/log/check.h"
47template <
typename Iterator>
51 using value_type =
typename std::iterator_traits<Iterator>::value_type;
58 Iterator
begin()
const {
return begin_; }
59 Iterator
end()
const {
return end_; }
62 size_t size()
const {
return end_ - begin_; }
74template <
typename Iterator>
78template <
typename Iterator>
80 std::pair<Iterator, Iterator> begin_end) {
87template <
typename MultiMap>
89 MultiMap& multi_map,
const typename MultiMap::key_type& key) {
92template <
typename MultiMap>
94 const MultiMap& multi_map,
const typename MultiMap::key_type& key) {
102template <
typename Container>
106 typename Container::const_reverse_iterator
begin()
const {
109 typename Container::const_reverse_iterator
end()
const {
return c_.rend(); }
114template <
typename Container>
122template <
typename IntegerType>
127#
if __cplusplus < 201703L
128 :
public std::iterator<std::input_iterator_tag, IntegerType>
134#if __cplusplus >= 201703L && __cplusplus < 202002L
135 using iterator_category = std::input_iterator_tag;
136 using pointer = IntegerType*;
137 using reference = IntegerType&;
149 return index_ == other.index_;
152 return index_ != other.index_;
155 return index_ < other.index_;
158 return index_ > other.index_;
161 return index_ <= other.index_;
164 return index_ >= other.index_;
234template <
typename IntegerType>
249template <
typename IndexT, const IndexT& sentinel,
typename Tag>
251#
if __cplusplus < 201703L
252 :
public std::iterator<std::input_iterator_tag, IndexT>
258#if __cplusplus >= 201703L && __cplusplus < 202002L
259 using iterator_category = std::input_iterator_tag;
260 using pointer = IndexT*;
261 using reference = IndexT&;
267 : index_(index), next_(next) {}
272 index_ = next_[
static_cast<ptrdiff_t
>(index_)];
277 index_ = next_[
static_cast<ptrdiff_t
>(index_)];
282 return l.index_ == r.index_;
285 return l.index_ != r.index_;
BeginEndReverseIteratorWrapper(const Container &c)
Container::const_reverse_iterator end() const
Container::const_reverse_iterator begin() const
BeginEndWrapper(Iterator begin, Iterator end)
BeginEndWrapper()=default
If Iterator is default-constructible, an empty range.
typename std::iterator_traits< Iterator >::value_type value_type
size_t size() const
Available only if Iterator is a random access iterator.
ChasingIterator(IndexT index, const IndexT *next)
friend bool operator!=(const ChasingIterator &l, const ChasingIterator &r)
ChasingIterator operator++(int)
ptrdiff_t difference_type
friend bool operator==(const ChasingIterator &l, const ChasingIterator &r)
ChasingIterator & operator++()
friend IntegerRangeIterator operator+(IntegerRangeIterator it, difference_type n)
bool operator<(const IntegerRangeIterator &other) const
bool operator==(const IntegerRangeIterator &other) const
friend IntegerRangeIterator operator+(difference_type n, IntegerRangeIterator it)
ptrdiff_t difference_type
IntegerRangeIterator operator--(int)
IntegerRangeIterator & operator--()
IntegerRangeIterator & operator+=(difference_type n)
IntegerRangeIterator & operator++()
bool operator!=(const IntegerRangeIterator &other) const
bool operator>=(const IntegerRangeIterator &other) const
bool operator>(const IntegerRangeIterator &other) const
IntegerRangeIterator(IntegerType value)
bool operator<=(const IntegerRangeIterator &other) const
IntegerType operator*() const
friend difference_type operator-(const IntegerRangeIterator l, const IntegerRangeIterator r)
IntegerRangeIterator & operator-=(difference_type n)
IntegerType operator[](difference_type n) const
friend IntegerRangeIterator operator-(IntegerRangeIterator it, difference_type n)
IntegerRangeIterator operator++(int)
IntegerRange(IntegerType begin, IntegerType end)
Requires begin <= end.
A collections of i/o utilities for the Graph classes in ./graph.h.
BeginEndReverseIteratorWrapper< Container > Reverse(const Container &c)
BeginEndWrapper< Iterator > BeginEndRange(Iterator begin, Iterator end)
BeginEndWrapper< typename MultiMap::iterator > EqualRange(MultiMap &multi_map, const typename MultiMap::key_type &key)