10#ifndef MCRL2_ATERMPP_ATERM_LIST_H
11#define MCRL2_ATERMPP_ATERM_LIST_H
22template <
typename Term>
62 :
aterm(detail::g_term_pool().empty_list())
99 explicit term_list(Iter first, Iter last,
typename std::enable_if<std::is_base_of<
100 std::bidirectional_iterator_tag,
101 typename std::iterator_traits<Iter>::iterator_category
102 >::value>::type* =
nullptr) :
103 aterm(detail::make_list_backward<Term,Iter,
104 detail::do_not_convert_term<Term> >(first, last,detail::do_not_convert_term<Term>()))
116 template <
class Iter,
class ATermConverter>
117 explicit term_list(Iter first, Iter last,
const ATermConverter& convert_to_aterm,
118 typename std::enable_if<std::is_base_of<
119 std::bidirectional_iterator_tag,
120 typename std::iterator_traits<Iter>::iterator_category
121 >::value>::type* = 0):
122 aterm(detail::make_list_backward<Term,Iter,ATermConverter>(first, last, convert_to_aterm))
136 template <
class Iter,
class ATermConverter,
class ATermFilter>
137 explicit term_list(Iter first, Iter last,
const ATermConverter& convert_to_aterm,
const ATermFilter& aterm_filter,
138 typename std::enable_if<std::is_base_of<
139 std::bidirectional_iterator_tag,
140 typename std::iterator_traits<Iter>::iterator_category
141 >::value>::type* = 0):
142 aterm(detail::make_list_backward<Term,Iter,ATermConverter,ATermFilter>(first, last, convert_to_aterm, aterm_filter))
153 template <
class Iter>
155 typename std::enable_if< !std::is_base_of<
156 std::bidirectional_iterator_tag,
157 typename std::iterator_traits<Iter>::iterator_category
158 >::value>::type* =
nullptr):
159 aterm(detail::make_list_forward<Term,Iter,detail::do_not_convert_term<Term> >
160 (first, last, detail::do_not_convert_term<Term>()))
175 template <
class Iter,
class ATermConverter>
176 explicit term_list(Iter first, Iter last,
const ATermConverter& convert_to_aterm,
177 typename std::enable_if< !std::is_base_of<
178 std::bidirectional_iterator_tag,
179 typename std::iterator_traits<Iter>::iterator_category
180 >::value>::type* =
nullptr):
181 aterm(detail::make_list_forward<Term,Iter,ATermConverter>
182 (first, last, convert_to_aterm))
199 template <
class Iter,
class ATermConverter,
class ATermFilter>
200 explicit term_list(Iter first, Iter last,
const ATermConverter& convert_to_aterm,
const ATermFilter& aterm_filter,
201 typename std::enable_if< !std::is_base_of<
202 std::random_access_iterator_tag,
203 typename std::iterator_traits<Iter>::iterator_category
204 >::value>::type* =
nullptr):
205 aterm(detail::make_list_forward<Term,Iter,ATermConverter>
206 (first, last, convert_to_aterm, aterm_filter))
215 :
aterm(detail::make_list_backward<Term,
217 detail::do_not_convert_term<Term> >
228 return (
static_cast<const detail::_aterm_list<Term>&
>(*
m_term)).tail();
241 return static_cast<const detail::_aterm_list<Term>&
>(*m_term).head();
250 template<
typename ...Args>
306 return std::numeric_limits<std::size_t>::max();
324template <
class Term,
class Iter>
326 std::bidirectional_iterator_tag,
327 typename std::iterator_traits<Iter>::iterator_category >::value>::type* =
nullptr)
331 assert(!target.defined() || target.type_is_list());
342template <
class Term,
class Iter,
class ATermConverter>
344 typename std::enable_if<std::is_base_of<
345 std::bidirectional_iterator_tag,
346 typename std::iterator_traits<Iter>::iterator_category
347 >::value>::type* = 0)
349 detail::make_list_backward<Term,Iter,ATermConverter>(target, first, last, convert_to_aterm);
350 assert(!target.defined() || target.type_is_list());
363template <
class Term,
class Iter,
class ATermConverter,
class ATermFilter>
365 typename std::enable_if<std::is_base_of<
366 std::bidirectional_iterator_tag,
367 typename std::iterator_traits<Iter>::iterator_category
368 >::value>::type* = 0)
370 detail::make_list_backward<Term,Iter,ATermConverter,ATermFilter>(target, first, last, convert_to_aterm, aterm_filter);
371 assert(!target.defined() || target.type_is_list());
381template <
class Term,
class Iter>
383 typename std::enable_if< !std::is_base_of<
384 std::bidirectional_iterator_tag,
385 typename std::iterator_traits<Iter>::iterator_category
386 >::value>::type* =
nullptr)
388 detail::make_list_forward<Term,Iter,detail::do_not_convert_term<Term> >
390 assert(!target.defined() || target.type_is_list());
404template <
class Term,
class Iter,
class ATermConverter>
406 typename std::enable_if< !std::is_base_of<
407 std::bidirectional_iterator_tag,
408 typename std::iterator_traits<Iter>::iterator_category
409 >::value>::type* =
nullptr)
411 detail::make_list_forward<Term,Iter,ATermConverter>
412 (target, first, last, convert_to_aterm);
413 assert(!target.defined() || target.type_is_list());
429template <
class Term,
class Iter,
class ATermConverter,
class ATermFilter>
431 typename std::enable_if< !std::is_base_of<
432 std::random_access_iterator_tag,
433 typename std::iterator_traits<Iter>::iterator_category
434 >::value>::type* =
nullptr)
436 detail::make_list_forward<Term,Iter,ATermConverter>
437 (target, first, last, convert_to_aterm, aterm_filter);
438 assert(!target.defined() || target.type_is_list());
449 typename std::initializer_list<Term>::const_iterator,
452 assert(!target.defined() || target.type_is_list());
463template <
typename T >
464struct is_container_impl<
atermpp::term_list< T > > :
public std::true_type
469class _aterm_list :
public _aterm_appl<2>
473 const Term&
head()
const {
return static_cast<const Term&
>(
arg(0)); }
476 const term_list<Term>&
tail()
const {
return static_cast<const term_list<Term>&
>(
arg(1)); }
478 std::size_t size()
const
481 for(_aterm_list
const* i=
this;
482 i->function()!=detail::g_term_pool().as_empty_list();
483 i=
static_cast<_aterm_list const*
>(
address(i->tail())))
504template <
typename Term>
513template <
typename Term>
516 const std::function<
bool(
const Term&,
const Term&)>& ordering
517 = [](
const Term& t1,
const Term& t2){
return t1<t2;});
530template <
typename Term1,
typename Term2>
532typename std::conditional<std::is_convertible<Term2,Term1>::value,term_list<Term1>,term_list<Term2>>::type
533operator+(
const term_list<Term1>& l,
const term_list<Term2>& m);
542template <
typename Term>
544term_list<Term>
push_back(
const term_list<Term>& l,
const Term& el);
550 return std::vector<T>(x.
begin(), x.
end());
557 return std::set<T>(x.
begin(), x.
end());
586 std::hash<atermpp::aterm> hasher;
The term_appl class represents function application.
A class containing some type traits.
aterm()
Default constructor.
This class stores a term followed by N arguments. Where N should be equal to the arity of the functio...
const function_symbol & function() const noexcept
const function_symbol & as_empty_list() noexcept
aterm & empty_list() noexcept
Reverse iterator for term_list.
size_type size() const
Returns the size of the term_list.
term_list(const term_list< Term > &t) noexcept
Copy constructor.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Term value_type
The type of object, T stored in the term_list.
const_reverse_iterator rend() const
Returns a const_iterator pointing to the end of the term_list.
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, const ATermFilter &aterm_filter, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last, converting and filtering the list.
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, const ATermFilter &aterm_filter, typename std::enable_if< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list from the elements from first to last converting and filtering the elements before...
term_list(Iter first, Iter last, typename std::enable_if< !std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list from the elements from first to last.
std::size_t size_type
An unsigned integral type.
term_list & operator=(const term_list &other) noexcept=default
This class has user-declared copy constructor so declare copy and move assignment.
reverse_term_list_iterator< Term > const_reverse_iterator
Const iterator used to iterate through an term_list.
const Term & const_reference
Const reference to T.
const term_list< Term > & tail() const
Returns the tail of the list.
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, typename std::enable_if< !std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list from the elements from first to last converting the elements before inserting.
const Term & front() const
Returns the first element of the list.
term_list(term_list< Term > &&t) noexcept
Move constructor.
ptrdiff_t difference_type
A signed integral type.
term_list & operator=(term_list &&other) noexcept=default
void pop_front()
Removes the first element of the list.
term_list(const aterm &t) noexcept
Constructor from an aterm.
term_list_iterator< Term > iterator
Iterator used to iterate through an term_list.
Term & reference
Reference to T.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
size_type max_size() const
Returns the largest possible size of the term_list.
void emplace_front(Args &&... arguments)
Construct and insert a new element at the beginning of the current list.
term_list(Iter first, Iter last, const ATermConverter &convert_to_aterm, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=0)
Creates a term_list with the elements from first to last converting the elements before inserting.
term_list_iterator< Term > const_iterator
Const iterator used to iterate through an term_list.
Term * pointer
Pointer to T.
term_list(detail::_aterm_appl<> *t) noexcept
Constructor for term lists from internally constructed terms delivered as reference.
bool empty() const
Returns true if the list's size is 0.
term_list(std::initializer_list< Term > init)
A constructor based on an initializer list.
term_list(Iter first, Iter last, typename std::enable_if< std::is_base_of< std::bidirectional_iterator_tag, typename std::iterator_traits< Iter >::iterator_category >::value >::type *=nullptr)
Creates a term_list with the elements from first to last.
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
const_reverse_iterator rbegin() const
Returns a const_reverse_iterator pointing to the end of the term_list.
term_list() noexcept
Default constructor. Creates an empty list.
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
bool defined() const
Returns true if this term is not equal to the term assigned by the default constructor of aterms,...
const detail::_aterm * m_term
MCRL2_EXPORT bool init(rewriter_interface *i, RewriterCompilingJitty *this_rewriter)
_aterm * address(const unprotected_aterm_core &t)
aterm_pool & g_term_pool()
obtain a reference to the global aterm pool.
aterm make_list_backward(Iter first, Iter last, ATermConverter convert_to_aterm)
Constructs a list starting from first to last. The iterators are traversed backwards and each element...
The main namespace for the aterm++ library.
void make_term_list(term_list< Term > &target)
Make an empty list and put it in target;.
term_list< aterm > aterm_list
A term_list with elements of type aterm.
std::set< T > as_set(const atermpp::term_list< T > &x)
Converts the given term list to a set.
term_list< Term > sort_list(const term_list< Term > &l, const std::function< bool(const Term &, const Term &)> &ordering=[](const Term &t1, const Term &t2){ return t1< t2;})
Returns the list with the elements sorted according to the <-operator on the addresses of terms.
term_list< Term > reverse(const term_list< Term > &l)
Returns the list with the elements in reversed order.
std::conditional< std::is_convertible< Term2, Term1 >::value, term_list< Term1 >, term_list< Term2 > >::type operator+(const term_list< Term1 > &l, const term_list< Term2 > &m)
Returns the concatenation of two lists with convertible element types.
std::vector< T > as_vector(const atermpp::term_list< T > &x)
Converts the given term list to a vector.
term_list< Term > push_back(const term_list< Term > &l, const Term &el)
Appends a new element at the end of the list. Note that the complexity of this function is O(n),...
const data_expression & arg(const data_expression &e)
Function for projecting out argument. arg from an application.
function_symbol head(const sort_expression &s)
Constructor for function symbol head.
function_symbol tail(const sort_expression &s)
Constructor for function symbol tail.
void swap(atermpp::unprotected_aterm_core &t1, atermpp::unprotected_aterm_core &t2) noexcept
Swaps two aterms.
std::size_t operator()(const atermpp::term_list< Term > &l) const
A specialization of the standard std::hash function.