mCRL2
Loading...
Searching...
No Matches
sequence.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_UTILITIES_SEQUENCE_H
13#define MCRL2_UTILITIES_SEQUENCE_H
14
15#include <iterator>
16#include <vector>
17
18namespace mcrl2
19{
20
21namespace utilities
22{
23
25namespace detail
26{
27
29struct foreach_sequence_assign
30{
34 template <typename T1, typename T2>
35 void operator()(T1& t1, const T2& t2) const
36 {
37 t1 = t2;
38 }
39};
40
47template <typename Iter1, typename Iter2, typename SequenceFunction, typename Assign>
48void foreach_sequence_impl(Iter1 first, Iter1 last, Iter2 i, SequenceFunction f, Assign assign)
49{
50 if (first == last)
51 {
52 f();
53 }
54 else
55 {
56 for (auto j = first->begin(); j != first->end(); ++j)
57 {
58 assign(*i, *j);
59 foreach_sequence_impl(std::next(first), last, std::next(i), f, assign);
60 }
61 }
62}
63
64} // namespace detail
66
77template <typename SequenceContainer,
78 typename OutIter,
79 typename SequenceFunction,
80 typename Assign>
81void foreach_sequence(const SequenceContainer& X, OutIter i, SequenceFunction f, Assign assign)
82{
83 detail::foreach_sequence_impl(X.begin(),
84 X.end(),
85 i,
86 f,
87 assign
88 );
89}
90
99template <typename SequenceContainer,
100 typename OutIter,
101 typename SequenceFunction>
102void foreach_sequence(const SequenceContainer& X, OutIter i, SequenceFunction f)
103{
104 foreach_sequence(X, i, f, detail::foreach_sequence_assign());
105}
106
107} // namespace utilities
108
109} // namespace mcrl2
110
111#endif // MCRL2_UTILITIES_SEQUENCE_H
const_iterator end() const
const_iterator begin() const
const function_symbol & first()
Constructor for function symbol @first.
Definition nat1.h:1791
void foreach_sequence(const SequenceContainer &X, OutIter i, SequenceFunction f, Assign assign)
Algorithm for generating sequences. Given a sequence [X1, ..., Xn], where each element Xi is a sequen...
Definition sequence.h:81
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72