mCRL2
Loading...
Searching...
No Matches
atermpp::term_balanced_tree< Term > Class Template Reference

Read-only balanced binary tree of terms. More...

#include <aterm_balanced_tree.h>

Inheritance diagram for atermpp::term_balanced_tree< Term >:
atermpp::aterm atermpp::aterm_core atermpp::unprotected_aterm_core

Classes

class  iterator
 

Public Types

using value_type = Term
 The type of object, T stored in the term_balanced_tree.
 
using pointer = Term *
 Pointer to T.
 
using reference = Term &
 Reference to T.
 
using const_reference = const Term
 Const reference to T.
 
using size_type = std::size_t
 An unsigned integral type.
 
using difference_type = ptrdiff_t
 A signed integral type.
 
- Public Types inherited from atermpp::aterm
using size_type = std::size_t
 An unsigned integral type.
 
using difference_type = ptrdiff_t
 A signed integral type.
 
using iterator = term_appl_iterator< aterm >
 Iterator used to iterate through an term_appl.
 
using const_iterator = term_appl_iterator< aterm >
 Const iterator used to iterate through an term_appl.
 

Public Member Functions

 term_balanced_tree ()
 Default constructor. Creates an empty tree.
 
 term_balanced_tree (const term_balanced_tree &) noexcept=default
 Copy constructor.
 
 term_balanced_tree (term_balanced_tree &&) noexcept=default
 Move constructor.
 
term_balanced_tree & operator= (const term_balanced_tree &) noexcept=default
 Assignment operator.
 
term_balanced_tree & operator= (term_balanced_tree &&) noexcept=default
 Move assign operator.
 
 term_balanced_tree (const aterm &tree)
 Construction from aterm.
 
template<typename ForwardTraversalIterator >
 term_balanced_tree (ForwardTraversalIterator first, const std::size_t size)
 Creates an term_balanced_tree with a copy of a range.
 
template<typename ForwardTraversalIterator , typename Transformer >
 term_balanced_tree (ForwardTraversalIterator first, const std::size_t size, Transformer transformer)
 Creates an term_balanced_tree with a copy of a range, where a transformer is applied to each term before adding it to the tree..
 
const aterm & left_branch () const
 Get the left branch of the tree.
 
const aterm & right_branch () const
 Get the left branch of the tree.
 
const Term & operator[] (std::size_t position) const
 Element indexing operator.
 
const Term & element_at (std::size_t position, std::size_t size) const
 Get an element at the indicated position.
 
size_type size () const
 Returns the size of the term_balanced_tree.
 
bool empty () const
 Returns true if tree is empty.
 
bool is_node () const
 Returns true iff the tree is a node with a left and right subtree.
 
iterator begin () const
 Returns an iterator pointing to the beginning of the term_balanced_tree.
 
iterator end () const
 Returns an iterator pointing to the end of the term_balanced_tree.
 
- Public Member Functions inherited from atermpp::aterm
 aterm ()
 Default constructor.
 
 aterm (const aterm &other) noexcept=default
 This class has user-declared copy constructor so declare default copy and move operators.
 
aterm & operator= (const aterm &other) noexcept=default
 
 aterm (aterm &&other) noexcept=default
 
aterm & operator= (aterm &&other) noexcept=default
 
template<class ForwardIterator >
requires (mcrl2::utilities::is_iterator<ForwardIterator>::value && !std::is_same_v<typename ForwardIterator::iterator_category, std::input_iterator_tag> && !std::is_same_v<typename ForwardIterator::iterator_category, std::output_iterator_tag>)
 aterm (const function_symbol &sym, ForwardIterator begin, ForwardIterator end)
 Constructor that provides an aterm based on a function symbol and forward iterator providing the arguments.
 
template<class InputIterator >
requires mcrl2::utilities::is_iterator<InputIterator>
 aterm (const function_symbol &sym, InputIterator begin, InputIterator end)
 Constructor that provides an aterm based on a function symbol and an input iterator providing the arguments.
 
template<class InputIterator , class TermConverter >
requires mcrl2::utilities::is_iterator<InputIterator>
 aterm (const function_symbol &sym, InputIterator begin, InputIterator end, TermConverter converter)
 Constructor.
 
template<typename... Terms>
 aterm (const function_symbol &symbol, const Terms &... arguments)
 Constructor for n-arity function application.
 
const function_symbol & function () const
 Returns the function symbol belonging to an aterm.
 
size_type size () const
 Returns the number of arguments of this term.
 
bool empty () const
 Returns true if the term has no arguments.
 
const_iterator begin () const
 Returns an iterator pointing to the first argument.
 
const_iterator end () const
 Returns a const_iterator pointing past the last argument.
 
constexpr size_type max_size () const
 Returns the largest possible number of arguments.
 
const aterm & operator[] (const size_type i) const
 Returns the i-th argument.
 
- Public Member Functions inherited from atermpp::aterm_core
 aterm_core () noexcept
 Default constructor.
 
 ~aterm_core () noexcept
 Standard destructor.
 
 aterm_core (const detail::_aterm *t) noexcept
 Constructor based on an internal term data structure. This is not for public use.
 
 aterm_core (const aterm_core &other) noexcept
 Copy constructor.
 
 aterm_core (aterm_core &&other) noexcept
 Move constructor.
 
aterm_core & operator= (const aterm_core &other) noexcept
 Assignment operator.
 
aterm_core & assign (const aterm_core &other, detail::thread_aterm_pool &pool) noexcept
 Assignment operator, to be used if busy and forbidden flags are explicitly available.
 
template<bool CHECK_BUSY_FLAG = true>
aterm_core & unprotected_assign (const aterm_core &other) noexcept
 Assignment operator, to be used when the busy flags do not need to be set.
 
aterm_core & operator= (aterm_core &&other) noexcept
 Move assignment operator.
 
- Public Member Functions inherited from atermpp::unprotected_aterm_core
 unprotected_aterm_core () noexcept
 Default constuctor.
 
 unprotected_aterm_core (const detail::_aterm *term) noexcept
 Constructor.
 
bool type_is_appl () const noexcept
 Dynamic check whether the term is an aterm.
 
bool type_is_int () const noexcept
 Dynamic check whether the term is an aterm_int.
 
bool type_is_list () const noexcept
 Dynamic check whether the term is an aterm_list.
 
bool operator== (const unprotected_aterm_core &t) const
 Comparison operator.
 
std::weak_ordering operator<=> (const unprotected_aterm_core &t) const
 Comparison operator for two unprotected aterms.
 
bool defined () const
 Returns true if this term is not equal to the term assigned by the default constructor of aterms, aterm_appls and aterm_int.
 
void swap (unprotected_aterm_core &t) noexcept
 Swaps this term with its argument.
 
const function_symbol & function () const
 Yields the function symbol in an aterm.
 

Protected Member Functions

 term_balanced_tree (detail::_term_appl *t)
 
- Protected Member Functions inherited from atermpp::aterm
 aterm (detail::_term_appl *t)
 Constructor.
 

Static Protected Member Functions

static const function_symbol & tree_empty_function ()
 
static const function_symbol & tree_single_node_function ()
 
static const function_symbol & tree_node_function ()
 
static const aterm & empty_tree ()
 
template<typename ForwardTraversalIterator , class Transformer >
static void make_tree_helper (aterm &result, ForwardTraversalIterator &p, const std::size_t size, Transformer transformer)
 
template<typename ForwardTraversalIterator , class Transformer >
static void make_tree (aterm &result, ForwardTraversalIterator &p, const std::size_t size, Transformer transformer)
 

Friends

template<class Term1 , class ForwardTraversalIterator , class Transformer >
void make_term_balanced_tree (term_balanced_tree< Term1 > &result, ForwardTraversalIterator p, std::size_t size, Transformer transformer)
 

Additional Inherited Members

- Protected Attributes inherited from atermpp::unprotected_aterm_core
const detail::_aterm * m_term
 

Detailed Description

template<typename Term>
class atermpp::term_balanced_tree< Term >

Read-only balanced binary tree of terms.

Definition at line 41 of file aterm_balanced_tree.h.

Member Typedef Documentation

◆ const_reference

template<typename Term >
using atermpp::term_balanced_tree< Term >::const_reference = const Term

Const reference to T.

Definition at line 128 of file aterm_balanced_tree.h.

◆ difference_type

template<typename Term >
using atermpp::term_balanced_tree< Term >::difference_type = ptrdiff_t

A signed integral type.

Definition at line 134 of file aterm_balanced_tree.h.

◆ pointer

template<typename Term >
using atermpp::term_balanced_tree< Term >::pointer = Term*

Pointer to T.

Definition at line 122 of file aterm_balanced_tree.h.

◆ reference

template<typename Term >
using atermpp::term_balanced_tree< Term >::reference = Term&

Reference to T.

Definition at line 125 of file aterm_balanced_tree.h.

◆ size_type

template<typename Term >
using atermpp::term_balanced_tree< Term >::size_type = std::size_t

An unsigned integral type.

Definition at line 131 of file aterm_balanced_tree.h.

◆ value_type

template<typename Term >
using atermpp::term_balanced_tree< Term >::value_type = Term

The type of object, T stored in the term_balanced_tree.

Definition at line 119 of file aterm_balanced_tree.h.

Constructor & Destructor Documentation

◆ term_balanced_tree() [1/7]

template<typename Term >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( detail::_term_appl *  t)
inlineexplicitprotected

Definition at line 112 of file aterm_balanced_tree.h.

◆ term_balanced_tree() [2/7]

template<typename Term >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( )
inline

Default constructor. Creates an empty tree.

Definition at line 137 of file aterm_balanced_tree.h.

◆ term_balanced_tree() [3/7]

template<typename Term >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( const term_balanced_tree< Term > &  )
defaultnoexcept

Copy constructor.

◆ term_balanced_tree() [4/7]

template<typename Term >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( term_balanced_tree< Term > &&  )
defaultnoexcept

Move constructor.

◆ term_balanced_tree() [5/7]

template<typename Term >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( const aterm &  tree)
inlineexplicit

Construction from aterm.

Definition at line 154 of file aterm_balanced_tree.h.

◆ term_balanced_tree() [6/7]

template<typename Term >
template<typename ForwardTraversalIterator >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( ForwardTraversalIterator  first,
const std::size_t  size 
)
inline

Creates an term_balanced_tree with a copy of a range.

Parameters
firstThe start of a range of elements.
sizeThe size of the range of elements.

Definition at line 170 of file aterm_balanced_tree.h.

◆ term_balanced_tree() [7/7]

template<typename Term >
template<typename ForwardTraversalIterator , typename Transformer >
atermpp::term_balanced_tree< Term >::term_balanced_tree ( ForwardTraversalIterator  first,
const std::size_t  size,
Transformer  transformer 
)
inline

Creates an term_balanced_tree with a copy of a range, where a transformer is applied to each term before adding it to the tree..

Parameters
[in]firstThe start of a range of elements.
[in]sizeThe size of the range of elements.
[in]transformerA class with an operator() that is applied to each term before adding it to the tree.

Definition at line 181 of file aterm_balanced_tree.h.

Member Function Documentation

◆ begin()

template<typename Term >
iterator atermpp::term_balanced_tree< Term >::begin ( ) const
inline

Returns an iterator pointing to the beginning of the term_balanced_tree.

Returns
The beginning of the list.

Definition at line 408 of file aterm_balanced_tree.h.

◆ element_at()

template<typename Term >
const Term & atermpp::term_balanced_tree< Term >::element_at ( std::size_t  position,
std::size_t  size 
) const
inline

Get an element at the indicated position.

Parameters
positionThe required position
sizeThe number of elements in the tree. This is required to make the complexity logarithmic.

By providing the size this operation is logarithmic. If a wrong size is provided the outcome is not determined. See also operator [].

Returns
The element at the indicated position.

Definition at line 221 of file aterm_balanced_tree.h.

◆ empty()

template<typename Term >
bool atermpp::term_balanced_tree< Term >::empty ( ) const
inline

Returns true if tree is empty.

Returns
True iff the tree is empty.

Definition at line 276 of file aterm_balanced_tree.h.

◆ empty_tree()

template<typename Term >
static const aterm & atermpp::term_balanced_tree< Term >::empty_tree ( )
inlinestaticprotected

Definition at line 54 of file aterm_balanced_tree.h.

◆ end()

template<typename Term >
iterator atermpp::term_balanced_tree< Term >::end ( ) const
inline

Returns an iterator pointing to the end of the term_balanced_tree.

Returns
The end of the list.

Definition at line 415 of file aterm_balanced_tree.h.

◆ is_node()

template<typename Term >
bool atermpp::term_balanced_tree< Term >::is_node ( ) const
inline

Returns true iff the tree is a node with a left and right subtree.

Returns
True iff the tree is a node with a left and right subtree.

Definition at line 283 of file aterm_balanced_tree.h.

◆ left_branch()

template<typename Term >
const aterm & atermpp::term_balanced_tree< Term >::left_branch ( ) const
inline

Get the left branch of the tree.

It is assumed that the tree is a node with a left branch.

Returns
A reference t the left subtree of the current tree

Definition at line 189 of file aterm_balanced_tree.h.

◆ make_tree()

template<typename Term >
template<typename ForwardTraversalIterator , class Transformer >
static void atermpp::term_balanced_tree< Term >::make_tree ( aterm &  result,
ForwardTraversalIterator &  p,
const std::size_t  size,
Transformer  transformer 
)
inlinestaticprotected

Definition at line 92 of file aterm_balanced_tree.h.

◆ make_tree_helper()

template<typename Term >
template<typename ForwardTraversalIterator , class Transformer >
static void atermpp::term_balanced_tree< Term >::make_tree_helper ( aterm &  result,
ForwardTraversalIterator &  p,
const std::size_t  size,
Transformer  transformer 
)
inlinestaticprotected

Definition at line 57 of file aterm_balanced_tree.h.

◆ operator=() [1/2]

template<typename Term >
term_balanced_tree & atermpp::term_balanced_tree< Term >::operator= ( const term_balanced_tree< Term > &  )
defaultnoexcept

Assignment operator.

◆ operator=() [2/2]

template<typename Term >
term_balanced_tree & atermpp::term_balanced_tree< Term >::operator= ( term_balanced_tree< Term > &&  )
defaultnoexcept

Move assign operator.

◆ operator[]()

template<typename Term >
const Term & atermpp::term_balanced_tree< Term >::operator[] ( std::size_t  position) const
inline

Element indexing operator.

Parameters
positionIndex in the tree.

This operation behaves linearly with respect to container size, because it must calculate the size of the container. The operator element_at behaves logarithmically.

Definition at line 209 of file aterm_balanced_tree.h.

◆ right_branch()

template<typename Term >
const aterm & atermpp::term_balanced_tree< Term >::right_branch ( ) const
inline

Get the left branch of the tree.

It is assumed that the tree is a node with a left branch.

Returns
A reference t the left subtree of the current tree

Definition at line 198 of file aterm_balanced_tree.h.

◆ size()

template<typename Term >
size_type atermpp::term_balanced_tree< Term >::size ( ) const
inline

Returns the size of the term_balanced_tree.

This operator is linear in the size of the balanced tree.

Returns
The size of the tree.

Definition at line 262 of file aterm_balanced_tree.h.

◆ tree_empty_function()

template<typename Term >
static const function_symbol & atermpp::term_balanced_tree< Term >::tree_empty_function ( )
inlinestaticprotected

Definition at line 51 of file aterm_balanced_tree.h.

◆ tree_node_function()

template<typename Term >
static const function_symbol & atermpp::term_balanced_tree< Term >::tree_node_function ( )
inlinestaticprotected

Definition at line 53 of file aterm_balanced_tree.h.

◆ tree_single_node_function()

template<typename Term >
static const function_symbol & atermpp::term_balanced_tree< Term >::tree_single_node_function ( )
inlinestaticprotected

Definition at line 52 of file aterm_balanced_tree.h.

Friends And Related Symbol Documentation

◆ make_term_balanced_tree

template<typename Term >
template<class Term1 , class ForwardTraversalIterator , class Transformer >
void make_term_balanced_tree ( term_balanced_tree< Term1 > &  result,
ForwardTraversalIterator  p,
std::size_t  size,
Transformer  transformer 
)
friend

The documentation for this class was generated from the following file: