14#ifndef CPROVER_UTIL_RANGE_H
15#define CPROVER_UTIL_RANGE_H
25template <
typename iteratort,
typename outputt>
87 std::function<
value_type(
const typename iteratort::value_type &)>>
f)
92 if(this->underlying != this->underlying_end)
93 current = std::make_shared<outputt>((*this->
f)(*this->underlying));
100 std::function<
value_type(
const typename iteratort::value_type &)>>
110template <
typename iteratort>
153 return &(*underlying);
164 std::shared_ptr<std::function<
bool(
const value_type &)>>
f,
195template <
typename first_iteratort,
typename second_iteratort>
201 using pointer =
typename first_iteratort::pointer;
206 std::is_same<value_type, typename first_iteratort::value_type>::value,
207 "Concatenated iterators should have the same value type");
217 return !(*
this == other);
248 return &(*second_begin);
249 return &(*first_begin);
283 typename first_iteratort::value_type,
284 typename second_iteratort::value_type>;
300 return !(*
this == other);
312 "Zipped ranges should have the same size");
360 std::shared_ptr<value_type>
current =
nullptr;
368 "Zip ranges should have same size");
394template <
typename iteratort>
408 auto shared_f = std::make_shared<decltype(f)>(std::move(f));
420 template <
typename functiont>
423 using outputt =
typename std::invoke_result<functiont, value_type>::type;
425 std::function<
outputt(
const typename iteratort::value_type &)>>(
426 std::forward<functiont>(f));
434 template <
typename other_iteratort>
449 template <
bool same_size = true,
typename other_iteratort>
454 begin(),
end(), other.begin(), other.end());
456 end(),
end(), other.end(), other.end());
461 template <
bool same_size = true,
typename containert>
466 ranget<
decltype(container.begin())>{container.begin(), container.end()});
497 const iteratort &
end()
const
497 const iteratort &
end()
const {
…}
504 template <
typename containert>
510 template <
typename containert>
521template <
typename iteratort>
527template <
typename containert>
530 return ranget<
decltype(container.begin())>(
531 container.begin(), container.end());
537template <
typename multimapt>
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Iterator which only stops at elements for which some given function f is true.
void point_to_first_to_peek()
Ensure that the underlying iterator is always positioned on an element for which f is true.
reference operator*() const
typename iteratort::difference_type difference_type
typename iteratort::value_type value_type
typename iteratort::reference reference
filter_iteratort(std::shared_ptr< std::function< bool(const value_type &)> > f, iteratort underlying, iteratort end)
Filter between underlying and end using f.
typename iteratort::pointer pointer
std::shared_ptr< std::function< bool(const value_type &)> > f
bool operator==(const filter_iteratort &other) const
bool operator!=(const filter_iteratort &other) const
pointer operator->() const
filter_iteratort operator++(int)
Postincrement operator.
filter_iteratort & operator++()
Preincrement operator.
const iteratort underlying_end
std::forward_iterator_tag iterator_category
Iterator which applies some given function f after each increment and returns its result on dereferen...
value_type * operator->()
const value_type & operator*() const
std::shared_ptr< outputt > current
Stores the result of f at the current position of the iterator.
typename iteratort::difference_type difference_type
bool operator==(const map_iteratort &other) const
std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)> > f
bool operator!=(const map_iteratort &other) const
map_iteratort operator++(int)
Postincrement operator.
const value_type * operator->() const
map_iteratort(iteratort underlying, iteratort underlying_end, std::shared_ptr< std::function< value_type(const typename iteratort::value_type &)> > f)
map_iteratort & operator++()
Preincrement operator.
std::forward_iterator_tag iterator_category
ranget< iteratort > make_range(iteratort begin, iteratort end)
ranget< typename multimapt::const_iterator > equal_range(const multimapt &multimap, const typename multimapt::key_type &key)
Utility function to make equal_range method of multimap easier to use by returning a ranget object.
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
On increment, increments a first iterator and when the corresponding end iterator is reached,...
typename first_iteratort::difference_type difference_type
bool operator!=(const concat_iteratort &other) const
reference operator*() const
concat_iteratort operator++(int)
Postincrement operator.
typename first_iteratort::reference reference
typename first_iteratort::value_type value_type
typename first_iteratort::pointer pointer
concat_iteratort(first_iteratort first_begin, first_iteratort first_end, second_iteratort second_begin)
first_iteratort first_end
std::forward_iterator_tag iterator_category
pointer operator->() const
first_iteratort first_begin
second_iteratort second_begin
concat_iteratort & operator++()
Preincrement operator.
bool operator==(const concat_iteratort &other) const
A range is a pair of a begin and an end iterators.
ranget< zip_iteratort< iteratort, other_iteratort, same_size > > zip(ranget< other_iteratort > other)
Combine two ranges to make a range over pairs.
auto zip(containert &container) -> ranget< zip_iteratort< iteratort, decltype(container.begin()), same_size > >
ranget< iteratort > drop(std::size_t count) &&
Return an new range containing the same elements except for the first count elements.
ranget< iteratort > drop(std::size_t count) const &
Return an new range containing the same elements except for the first count elements.
ranget(iteratort begin, iteratort end)
ranget< filter_iteratort< iteratort > > filter(std::function< bool(const value_type &)> f)
const iteratort & end() const
auto map(functiont &&f)
The type of elements contained in the resulting range is deduced from the return type of f.
typename iteratort::value_type value_type
containert collect() const
Constructs a collection containing the values, which this range iterates over.
ranget< concat_iteratort< iteratort, other_iteratort > > concat(ranget< other_iteratort > other)
Zip two ranges to make a range of pairs.
typename first_iteratort::difference_type difference_type
zip_iteratort(first_iteratort _first_begin, first_iteratort _first_end, second_iteratort _second_begin, second_iteratort _second_end)
second_iteratort second_begin
first_iteratort first_begin
second_iteratort second_end
bool operator!=(const zip_iteratort &other) const
zip_iteratort operator++(int)
Postincrement operator.
reference operator*() const
first_iteratort first_end
std::shared_ptr< value_type > current
pointer operator->() const
std::forward_iterator_tag iterator_category
zip_iteratort & operator++()
Preincrement operator.
std::pair< typename first_iteratort::value_type, typename second_iteratort::value_type > value_type
bool operator==(const zip_iteratort &other) const