Line data Source code
1 : // Author(s): Wieger Wesselink, Jan Friso Groote, Maurice Laveaux. 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 : // 9 : /// \file mcrl2/atermpp/aterm_int.h 10 : /// \brief Term containing an integer. 11 : 12 : #ifndef MCRL2_ATERMPP_DETAIL_ATERM_LIST_H 13 : #define MCRL2_ATERMPP_DETAIL_ATERM_LIST_H 14 : 15 : #include "mcrl2/atermpp/detail/aterm.h" 16 : 17 : namespace atermpp 18 : { 19 : 20 : template <class Term> 21 : class term_list; 22 : 23 : typedef term_list<aterm> aterm_list; 24 : 25 : namespace detail 26 : { 27 : 28 : template <class Term> 29 : class _term_list; 30 : 31 : 32 : template <class Term> 33 : struct do_not_convert_term 34 : { 35 4352035 : void operator()(Term& result, const Term& t) const 36 : { 37 4352035 : result=t; 38 4352035 : } 39 : 40 42908382 : const Term& operator()(const Term& t) const 41 : { 42 42908382 : return t; 43 : } 44 : 45 158040 : Term& operator()(Term& t) const 46 : { 47 158040 : return t; 48 : } 49 : }; 50 : 51 : /// \brief Constructs a list starting from first to last. The iterators are traversed backwards and each element is 52 : /// converted using the TermConverter. 53 : /// \details The functions make_list_backward and make_list_forward with three and four arguments are almost the same. 54 : /// The reason for this is that there is a 5% loss of speed of the toolset when merging these two functions. 55 : /// This is caused by storing and protecting the intermediate value of the converted aterm. See Term t = convert_to_aterm(...). 56 : template <typename Term, typename Iter, typename ATermConverter> 57 : inline aterm make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm); 58 : 59 : /// \brief Constructs a list starting from first to last where the result is put in result. 60 : template <class Term, class Iter, class ATermConverter> 61 : inline void make_list_backward(term_list<Term>& result, Iter first, Iter last, ATermConverter convert_to_aterm); 62 : 63 : 64 : /// \brief Constructs a list starting from first to last. The iterators are traversed backwards and each element is 65 : /// converted using the TermConverter and inserted whenever TermFilter yields true for the converted element. 66 : template <typename Term, typename Iter, typename ATermConverter, typename ATermFilter> 67 : inline aterm make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter); 68 : 69 : /// \brief Construct a list iterating from the last to the first element. Result is put in the variable result. 70 : template <class Term, class Iter, class ATermConverter, class ATermFilter> 71 : inline void make_list_backward(term_list<Term>& result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter); 72 : 73 : /// \brief Constructs a list starting from first to last. Each element is converted using the TermConverter. 74 : template <typename Term, class Iter, class ATermConverter> 75 : aterm make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm); 76 : 77 : /// \brief Constructs a list starting from first to last. Each element is converted using the TermConverter. 78 : template <typename Term, class Iter, class ATermConverter> 79 : inline void make_list_forward(term_list<Term>& result, Iter first, Iter last, ATermConverter convert_to_aterm); 80 : 81 : /// \brief Constructs a list starting from the first iterator element to the last. The result is put into the variable result. 82 : template <class Term, class Iter, class ATermConverter> 83 : inline void make_list_backward(term_list<Term>& result, Iter first, Iter last, ATermConverter convert_to_aterm); 84 : 85 : /// \brief Constructs a list starting from first to last. Each element is converted using the TermConverter and inserted 86 : /// whenever TermFilter yields true for the converted element. 87 : /// \details Will first store the converted elements in an array and then insert them into the list. 88 : template <typename Term, class Iter, class ATermConverter, class ATermFilter> 89 : aterm make_list_forward(Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter); 90 : 91 : /// \brief Constructs a list traversing the iterator from first to last, putting the result in place in the variable result. 92 : template <class Term, class Iter, class ATermConverter, class ATermFilter> 93 : inline void make_list_forward(term_list<Term>& result, Iter first, Iter last, ATermConverter convert_to_aterm, ATermFilter aterm_filter); 94 : 95 : } // namespace detail 96 : 97 : } // namespace atermpp 98 : 99 : #endif // MCRL2_ATERMPP_DETAIL_ATERM_INT_H