10#ifndef MCRL2_ATERMPP_ATERM_LIST_H
11#define MCRL2_ATERMPP_ATERM_LIST_H
13#include "mcrl2/atermpp/aterm.h"
14#include "mcrl2/atermpp/detail/aterm_list.h"
15#include "mcrl2/atermpp/detail/aterm_list_iterator.h"
16#include "mcrl2/atermpp/type_traits.h"
24template <
typename Term>
31 assert(!defined() || type_is_list());
36 using value_type = Term;
39 using pointer = Term*;
42 using reference = Term&;
45 using const_reference =
const Term&;
51 using difference_type = ptrdiff_t;
72 assert(type_is_list());
80 assert(!defined() || type_is_list());
88 assert(!defined() || type_is_list());
160 template <
class Iter>
268 template<
typename ...Args>
288 return m_term->function() == detail::g_term_pool().as_empty_list();
295 return const_iterator(m_term);
300 const_iterator
end()
const
302 return const_iterator(detail::address(detail::g_term_pool().empty_list()));
310 return const_reverse_iterator(m_term);
315 const_reverse_iterator
rend()
const
317 return const_reverse_iterator();
324 return std::numeric_limits<std::size_t>::max();
334 target=atermpp::down_cast<term_list<Term>>(detail::g_term_pool().empty_list());
489template <
typename T >
530template <
typename Term,
typename Compare =
std::
less<
Term>>
534 return std::is_sorted(l.begin(), l.end(), ordering);
542template <
typename Term>
551template <
typename Term,
typename Compare =
std::
less<
Term>>
561template <
typename Term,
typename Compare =
std::
less<
Term>>
571template <
typename Term,
typename Compare =
std::
less<
Term>>
596template <
typename Term>
604 return std::vector<T>(x.begin(), x.end());
611 return std::set<T>(x.begin(), x.end());
647#include "mcrl2/atermpp/detail/aterm_list_implementation.h"
An integer term stores a single std::size_t value. It carries no arguments.
aterm_int(std::size_t value)
Constructs an integer term from a value.
aterm_int(const aterm &t)
Constructs an integer term from an aterm.
std::size_t value() const noexcept
Provide the value stored in an aterm.
void swap(aterm_int &t) noexcept
Swaps two integer terms without changing the protection.
aterm_int() noexcept=default
Default constructor.
The interface for a class that reads aterm from a stream. The default constructed term aterm() indica...
virtual void get(aterm &t)=0
Reads an aterm from this stream.
~aterm_istream() override
The interface for a class that writes aterm to a stream. Every written term is retrieved by the corre...
virtual void put(const aterm &term)=0
Write the given term to the stream.
~aterm_ostream() override
A helper class to restore the state of the aterm_{i,o}stream objects upon destruction....
aterm_stream_state(aterm_stream_state &&)=delete
aterm_stream_state & operator=(aterm_stream_state &&)=delete
aterm_transformer * m_transformer
aterm_stream_state(aterm_stream &stream)
aterm_stream_state(const aterm_stream_state &)=delete
aterm_stream_state & operator=(const aterm_stream_state &)=delete
The general aterm stream interface, which enables the use of a transformer to change the written/read...
aterm_transformer * m_transformer
aterm_transformer * get_transformer() const
void set_transformer(aterm_transformer transformer)
Sets the given transformer to be applied to following writes.
aterm(const aterm &other) noexcept=default
This class has user-declared copy constructor so declare default copy and move operators.
thread_aterm_pool(aterm_pool &global_pool)
std::stack< std::reference_wrapper< _aterm > > m_todo
A reusable todo stack.
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.
const_reverse_iterator rend() const
Returns a const_iterator pointing to the end of the term_list.
term_list & operator=(const term_list &other) noexcept=default
This class has user-declared copy constructor so declare copy and move assignment.
term_list(term_list< Term > &&t) noexcept
Move constructor.
term_list & operator=(term_list &&other) noexcept=default
term_list(const aterm &t) noexcept
Constructor from an aterm.
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(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.
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.
A unordered_map class in which aterms can be stored.
thread_aterm_pool & g_thread_term_pool()
A reference to the thread local term pool storage.
aterm_pool & g_aterm_pool_instance()
A reference to the global term pool storage.
thread_aterm_pool * g_main_thread_pool
Pointer to the main thread's pool; set on its first access and used by ~thread_aterm_pool to transfer...
mcrl2::utilities::shared_guard lock_shared_aterm_pool()
Acquires a shared lock on the global thread aterm pool.
std::array< std::byte, sizeof(aterm_pool)> g_aterm_pool_storage
Storage for a global term pool that is not initialized.
The main namespace for the aterm++ library.
term_list< Term > sort_list(const term_list< Term > &l, Compare ordering=Compare{})
Returns the list with the elements sorted according to given ordering which is by default the orderin...
aterm identity(const aterm &x)
The default transformer that maps each term to itself.
void make_term_list(term_list< Term > &target)
Make an empty list and put it in target;.
aterm_istream & operator>>(aterm_istream &stream, aterm &term)
Read the given term from the stream, but for aterm_list we want to use a specific one that performs v...
void read_term_from_binary_stream(std::istream &is, aterm &t)
Reads a term from a stream in binary aterm format.
bool is_sorted(const term_list< Term > &l, Compare ordering=Compare{})
Returns whether the given list is sorted according to the given ordering which is by default the stan...
aterm read_appl_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
std::set< T > as_set(const atermpp::term_list< T > &x)
Converts the given term list to a set.
aterm_int read_int_from_string(const std::string &s)
Reads an aterm_int from a string. The string can be in either binary or text format.
term_list< Term > insert_sorted(const Term &t, const term_list< Term > &l, Compare ordering=Compare{})
Returns the list with element t inserted in l lexicographically according to the provided ordering.
term_list< Term > reverse(const term_list< Term > &l)
Returns the list with the elements in reversed order.
aterm read_term_from_string(const std::string &s)
Reads an aterm from a string. The string can be in either binary or text format.
void add_deletion_hook(const function_symbol &, term_callback)
Check for reasonably sized aterm (32 bits, 4 bytes) This check might break on perfectly valid archite...
void write_term_to_text_stream(const aterm &t, std::ostream &os)
Writes term t to a stream in textual format.
aterm_istream & operator>>(aterm_istream &stream, aterm_transformer transformer)
Sets the given transformer to be applied to following reads.
void make_aterm_int(aterm_int &target, std::size_t value)
Constructs an integer term from a value.
std::vector< T > as_vector(const atermpp::term_list< T > &x)
Converts the given term list to a vector.
term_list< Term > merge_lists(const term_list< Term > &l1, const term_list< Term > &l2, Compare ordering=Compare{})
Returns the merged list sorted according to the given ordering, which is by default the ordering of a...
void read_term_from_text_stream(std::istream &is, aterm &t)
Reads a term from a stream which contains the term in textual format.
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),...
aterm_list read_list_from_string(const std::string &s)
Reads an aterm_list from a string. The string can be in either binary or text format.
void swap(atermpp::term_list< T > &t1, atermpp::term_list< T > &t2) noexcept
Swaps two term_lists.
void swap(atermpp::aterm_int &t1, atermpp::aterm_int &t2) noexcept
Swaps two aterm_ints.
std::size_t operator()(const atermpp::term_list< Term > &l) const
A specialization of the standard std::hash function.