# mcrl2/atermpp/aterm_list.h¶

Include file:

#include "mcrl2/atermpp/aterm_list.h"


## Typedefs¶

type atermpp::aterm_list

typedef for term_list< aterm >

A term_list with elements of type aterm.

## Functions¶

std::set<T> atermpp::as_set(const atermpp::term_list<T> &x)

Converts the given term list to a set.

std::vector<T> atermpp::as_vector(const atermpp::term_list<T> &x)

Converts the given term list to a vector.

void atermpp::make_term_list(term_list<Term> &target)

Make an empty list and put it in target;.

Parameters:

• target The variable to which the empty list is assigned.
void atermpp::make_term_list(term_list<Term> &target, 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 inserting.

The range is traversed from first to last. This requires to copy the elements internally, which is less efficient than this function with random access iterators as arguments. The operator () in the class ATermConverter is applied to each element before inserting it in the list. Elements are only inserted if the operator () of the class ATermFilter yields true when applied to such an element.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
• convert_to_aterm A class with a () operation, whic is applied to each element before it is put into the list.
• aterm_filter A class with an operator () that is used to determine whether elements can be inserted in the list.
void atermpp::make_term_list(term_list<Term> &target, 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.

It is assumed that the range can be traversed from last to first. The operator () in the class ATermConverter is applied to each element before inserting it in the list. Elements are only inserted if the operator () of the class ATermFilter yields true when applied to such an element.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
• convert_to_aterm A class with a () operation, which is applied to each element before it is put into the list.
• aterm_filter A class with an operator () that is used to determine whether elements can be inserted in the list.
void atermpp::make_term_list(term_list<Term> &target, 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.

The range is traversed from first to last. This requires to copy the elements internally, which is less efficient than this function with random access iterators as arguments. The operator () in the class ATermConverter is applied to each element before inserting it in the list.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
• convert_to_aterm A class with a () operation, which is applied to each element before it is put into the list.
void atermpp::make_term_list(term_list<Term> &target, 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.

It is assumed that the range can be traversed from last to first. The operator () in the class ATermConverter is applied to each element before inserting it in the list.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
• convert_to_aterm A class with a () operation, which is applied to each element before it is put into the list.
void atermpp::make_term_list(term_list<Term> &target, 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.

The range is traversed from first to last. This requires to copy the elements internally, which is less efficient than this function with random access iterators as arguments.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
void atermpp::make_term_list(term_list<Term> &target, 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.

It is assumed that the range can be traversed from last to first.

Parameters:

• target The variable to which the list is assigned.
• first The start of a range of elements.
• last The end of a range of elements.
void atermpp::make_term_list(term_list<Term> &target, std::initializer_list<Term> init)

A constructor based on an initializer list.

This constructor is not made explicit to conform to initializer lists in standard containers.

Parameters:

• target The variable to which the list is assigned.
• init The initialiser list.
std::conditional<std::is_convertible<Term2, Term1>::value, term_list<Term1>, term_list<Term2>>::type atermpp::operator+(const term_list<Term1> &l, const term_list<Term2> &m)

Returns the concatenation of two lists with convertible element types.

The type of the result is either the type of l, if the elements of m can be converted implicitly to the type of the elements of l. Otherwise if the elements of l can be converted implicitly to the type of the elements of m, the result type is that or m.

Parameters:

• l A list.
• m A list.

The complexity of this operator is linear in the length of l.

Returns: The concatenation of the lists l followed by m.
term_list<Term> atermpp::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), with n the number of elements in the list!!!

Parameters:

• l The list to which the term is appended.
• el A term.

Returns: The list l with elem appended at the end.

term_list<Term> atermpp::reverse(const term_list<Term> &l)

Returns the list with the elements in reversed order.

Parameters:

• l A list.

This operator is linear in the size of the list.

Returns: The reversed list.
term_list<Term> atermpp::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.

Parameters:

• l A list.
• ordering An total orderings relation on Term, by default the ordering relation on Terms.

This operator has complexity nlog n where n is the size of the list.

Returns: The sorted list.

## Functions¶

void std::swap(atermpp::term_list<T> &t1, atermpp::term_list<T> &t2) noexcept

Swaps two term_lists.

This operation is more efficient than exchanging terms by an assignment, as swapping does not require to change the protection of terms.

Parameters:

• t1 The first term
• t2 The second term