atermpp::term_balanced_tree

Include file:

#include "mcrl2/atermpp/aterm_balanced_tree.h
class atermpp::term_balanced_tree

Read-only balanced binary tree of terms.

Public types

type const_reference

typedef for const Term

Const reference to T.

type difference_type

typedef for ptrdiff_t

A signed integral type.

type pointer

typedef for Term *

Pointer to T.

type reference

typedef for Term &

Reference to T.

type size_type

typedef for std::size_t

An unsigned integral type.

type value_type

typedef for Term

The type of object, T stored in the term_balanced_tree.

Protected static member functions

static const aterm_appl &empty_tree()
static aterm_appl make_node(const term_balanced_tree &left_tree, const term_balanced_tree &right_tree)
static const atermpp::function_symbol &tree_empty_function()
static const function_symbol &tree_node_function()

Protected member functions

aterm_appl make_tree(ForwardTraversalIterator &p, const std::size_t size, Transformer transformer)
term_balanced_tree(detail::_term_appl *t)

Public member functions

iterator begin() const

Returns an iterator pointing to the beginning of the term_balanced_tree.

Returns: The beginning of the list.

const Term &element_at(std::size_t position, std::size_t size) const

Get an element at the indicated position.

Parameters:

  • position The required position
  • size The 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.
bool empty() const

Returns true if tree is empty.

Returns: True iff the tree is empty.

iterator end() const

Returns an iterator pointing to the end of the term_balanced_tree.

Returns: The end of the list.

bool is_node() const

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.

const term_balanced_tree<Term> &left_branch() const

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

term_balanced_tree &operator=(const term_balanced_tree&) noexcept = default

Assignment operator.

term_balanced_tree &operator=(term_balanced_tree&&) noexcept = default

Move assign operator.

const Term &operator[](std::size_t position) const

Element indexing operator.

Parameters:

  • position Index 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.

const term_balanced_tree<Term> &right_branch() const

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

size_type size() const

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.

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(const aterm &tree)

Construction from aterm.

term_balanced_tree(ForwardTraversalIterator first, const std::size_t size)

Creates an term_balanced_tree with a copy of a range.

Parameters:

  • first The start of a range of elements.
  • size The size of the range of elements.
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..

Parameters:

  • first The start of a range of elements.
  • size The size of the range of elements.
  • transformer A class with an operator() that is applied to each term before adding it to the tree.