0.12.0
Freundlich's C++ toolkit
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions
fcppt::container::tree::object< T > Class Template Reference

Detailed Description

template<typename T>
class fcppt::container::tree::object< T >

A tree data structure.

See the documentation of fcppt::container::tree::object to know more.

Public Types

typedef boost::ptr_list< objectchild_list
 
typedef fcppt::unique_ptr< objectunique_ptr
 
typedef T value_type
 
typedef child_list::size_type size_type
 
typedef child_list::difference_type difference_type
 
typedef child_list::reference reference
 
typedef child_list::const_reference const_reference
 
typedef child_list::iterator iterator
 
typedef child_list::const_iterator const_iterator
 
typedef
child_list::reverse_iterator 
reverse_iterator
 
typedef
child_list::const_reverse_iterator 
const_reverse_iterator
 
typedef tree::is_ptr_value< T > is_ptr_tree
 
typedef boost::mpl::eval_if
< is_ptr_tree,
fcppt::mpl::inner< T >
, boost::mpl::identity< T >
>::type 
stored_type
 The type to store, possibly extracted from ptr_value<T>
 
typedef boost::mpl::if_
< is_ptr_tree,
fcppt::unique_ptr< stored_type >
, stored_type >::type 
arg_base_type
 The type to forward to other functions (either T or unique_ptr<T>)
 
typedef boost::mpl::if_
< is_ptr_tree, arg_base_type,
arg_base_type const & >::type 
arg_type
 The type to pass to other functions (either T const & or unique_ptr<T>)
 
typedef boost::mpl::if_
< is_ptr_tree,
fcppt::scoped_ptr< stored_type >
, stored_type >::type 
holder_type
 The type that holds the stored type (either T or scoped_ptr<T>)
 

Public Member Functions

 object ()
 Constructs the tree using the default constructed value.
 
 object (arg_type)
 Constructs the object using the given value.
 
 object (object const &)
 Deeply copies a tree.
 
objectoperator= (object const &)
 Deeply assigns a tree.
 
 ~object ()
 
child_listchildren ()
 
child_list const & children () const
 
objectparent ()
 Returns a reference to the parent of this tree.
 
object const & parent () const
 Returns a reference to the parent of this tree.
 
objectparent_ptr ()
 Returns a pointer to the parent of this tree.
 
object const * parent_ptr () const
 Returns a pointer to the parent of this tree.
 
bool has_parent () const
 Returns if this tree has a parent.
 
void parent (object &)
 Sets a new parent.
 
unique_ptr release (iterator)
 Detaches the given child from the parent and returns it.
 
iterator child_position ()
 Returns an iterator pointing to the position in the parent's child container where this object resides.
 
const_iterator child_position () const
 Returns an iterator pointing to the position in the parent's child container where this object resides.
 
void value (arg_type)
 Sets a new value.
 
stored_typevalue ()
 Retrieves the tree's value.
 
stored_type const & value () const
 Retrieves the tree's value.
 
bool has_value () const
 Returns if this node holds a value Will always be true for normal trees. If the tree holds a ptr_value it depends on whether it has been initialized.
 
holder_typeholder ()
 Returns a reference to the holder type.
 
holder_type const & holder () const
 Returns a const reference to the holder type.
 
void push_back (unique_ptr)
 Inserts a new child at the end of the child list.
 
void push_back (arg_type)
 Inserts a new child at the end of the child list.
 
void pop_back ()
 Removes a child from the end of the child list.
 
void push_front (unique_ptr)
 Adds a child in front of the child list.
 
void push_front (arg_type)
 Adds a child in front of the child list.
 
void pop_front ()
 Removes a child from the front of the child list.
 
void clear ()
 Removes all children.
 
reference back ()
 Returns a reference to the last child.
 
const_reference back () const
 Returns a reference to the last child.
 
reference front ()
 Returns a reference to the first child.
 
const_reference front () const
 Returns a reference to the first child.
 
iterator begin ()
 Returns an iterator to the first child (if present)
 
iterator end ()
 Returns an iterator to "one past the last child", if present, otherwise returns begin .
 
const_iterator begin () const
 Returns an iterator to the first child (if present)
 
const_iterator end () const
 Returns an iterator to "one past the last child", if present, otherwise returns begin .
 
reverse_iterator rbegin ()
 Returns a reverse_iterator to the last element (if present)
 
reverse_iterator rend ()
 Returns a reverse_iterator to the first element (if present)
 
const_reverse_iterator rbegin () const
 Returns a const_reverse_iterator to the last element (if present)
 
const_reverse_iterator rend () const
 Returns a const_reverse_iterator to the first element (if present)
 
const_iterator cbegin () const
 Returns a const_iterator to the first child (if present)
 
const_iterator cend () const
 Returns a const_iterator to the first child (if present)
 
const_reverse_iterator crbegin () const
 Returns a const_reverse_iterator to the last element (if present)
 
const_reverse_iterator crend () const
 Returns a const_reverse_iterator to the first element (if present)
 
void insert (iterator, unique_ptr)
 Inserts an element before the given iterator.
 
void insert (iterator, arg_type)
 Inserts an element before the given iterator.
 
void erase (iterator)
 Erases a single element.
 
void erase (iterator, iterator)
 Erases a range.
 
size_type size () const
 Returns the number of children.
 
size_type max_size () const
 Returns the ptr_list's max_size.
 
bool empty () const
 Returns if the container is empty.
 
void swap (object &)
 Swaps with another tree.
 

Member Typedef Documentation

template<typename T>
typedef boost::mpl::if_< is_ptr_tree, fcppt::unique_ptr< stored_type >, stored_type >::type fcppt::container::tree::object< T >::arg_base_type

The type to forward to other functions (either T or unique_ptr<T>)

template<typename T>
typedef boost::mpl::if_< is_ptr_tree, arg_base_type, arg_base_type const & >::type fcppt::container::tree::object< T >::arg_type

The type to pass to other functions (either T const & or unique_ptr<T>)

template<typename T>
typedef boost::ptr_list< object > fcppt::container::tree::object< T >::child_list
template<typename T>
typedef child_list::const_iterator fcppt::container::tree::object< T >::const_iterator
template<typename T>
typedef child_list::const_reference fcppt::container::tree::object< T >::const_reference
template<typename T>
typedef child_list::const_reverse_iterator fcppt::container::tree::object< T >::const_reverse_iterator
template<typename T>
typedef child_list::difference_type fcppt::container::tree::object< T >::difference_type
template<typename T>
typedef boost::mpl::if_< is_ptr_tree, fcppt::scoped_ptr< stored_type >, stored_type >::type fcppt::container::tree::object< T >::holder_type

The type that holds the stored type (either T or scoped_ptr<T>)

template<typename T>
typedef tree::is_ptr_value< T > fcppt::container::tree::object< T >::is_ptr_tree
template<typename T>
typedef child_list::iterator fcppt::container::tree::object< T >::iterator
template<typename T>
typedef child_list::reference fcppt::container::tree::object< T >::reference
template<typename T>
typedef child_list::reverse_iterator fcppt::container::tree::object< T >::reverse_iterator
template<typename T>
typedef child_list::size_type fcppt::container::tree::object< T >::size_type
template<typename T>
typedef boost::mpl::eval_if< is_ptr_tree, fcppt::mpl::inner< T >, boost::mpl::identity< T > >::type fcppt::container::tree::object< T >::stored_type

The type to store, possibly extracted from ptr_value<T>

template<typename T>
typedef fcppt::unique_ptr< object > fcppt::container::tree::object< T >::unique_ptr
template<typename T>
typedef T fcppt::container::tree::object< T >::value_type

Constructor & Destructor Documentation

template<typename T >
object< T >::object ( )

Constructs the tree using the default constructed value.

template<typename T >
object< T >::object ( arg_type  _value)
explicit

Constructs the object using the given value.

template<typename T >
object< T >::object ( object< T > const &  _other)

Deeply copies a tree.

See Also
tree_copying
template<typename T >
object< T >::~object ( )

Member Function Documentation

template<typename T >
fcppt::container::tree::object< T >::reference object< T >::back ( )

Returns a reference to the last child.

Behaviour is undefined if empty is true.

template<typename T >
fcppt::container::tree::object< T >::const_reference object< T >::back ( ) const

Returns a reference to the last child.

Behaviour is undefined if empty is true.

template<typename T >
fcppt::container::tree::object< T >::iterator object< T >::begin ( )

Returns an iterator to the first child (if present)

template<typename T >
fcppt::container::tree::object< T >::const_iterator object< T >::begin ( ) const

Returns an iterator to the first child (if present)

template<typename T >
fcppt::container::tree::object< T >::const_iterator object< T >::cbegin ( ) const

Returns a const_iterator to the first child (if present)

template<typename T >
fcppt::container::tree::object< T >::const_iterator object< T >::cend ( ) const

Returns a const_iterator to the first child (if present)

template<typename T >
fcppt::container::tree::object< T >::iterator object< T >::child_position ( )

Returns an iterator pointing to the position in the parent's child container where this object resides.

Behaviour is undefined if has_parent is false

template<typename T >
fcppt::container::tree::object< T >::const_iterator object< T >::child_position ( ) const

Returns an iterator pointing to the position in the parent's child container where this object resides.

Behaviour is undefined if has_parent is false

template<typename T >
fcppt::container::tree::object< T >::child_list & object< T >::children ( )
template<typename T >
fcppt::container::tree::object< T >::child_list const & object< T >::children ( ) const
template<typename T >
void object< T >::clear ( )

Removes all children.

template<typename T >
fcppt::container::tree::object< T >::const_reverse_iterator object< T >::crbegin ( ) const

Returns a const_reverse_iterator to the last element (if present)

template<typename T >
fcppt::container::tree::object< T >::const_reverse_iterator object< T >::crend ( ) const

Returns a const_reverse_iterator to the first element (if present)

template<typename T >
bool object< T >::empty ( ) const

Returns if the container is empty.

template<typename T >
fcppt::container::tree::object< T >::iterator object< T >::end ( )

Returns an iterator to "one past the last child", if present, otherwise returns begin .

template<typename T >
fcppt::container::tree::object< T >::const_iterator object< T >::end ( ) const

Returns an iterator to "one past the last child", if present, otherwise returns begin .

template<typename T >
void object< T >::erase ( iterator  _it)

Erases a single element.

template<typename T >
void object< T >::erase ( iterator  _begin,
iterator  _end 
)

Erases a range.

template<typename T >
fcppt::container::tree::object< T >::reference object< T >::front ( )

Returns a reference to the first child.

Behaviour is undefined if empty is true.

template<typename T >
fcppt::container::tree::object< T >::const_reference object< T >::front ( ) const

Returns a reference to the first child.

Behaviour is undefined if empty is true.

template<typename T >
bool object< T >::has_parent ( ) const

Returns if this tree has a parent.

template<typename T >
bool object< T >::has_value ( ) const

Returns if this node holds a value Will always be true for normal trees. If the tree holds a ptr_value it depends on whether it has been initialized.

template<typename T >
fcppt::container::tree::object< T >::holder_type & object< T >::holder ( )

Returns a reference to the holder type.

This can be used to release the scoped_ptr if the tree has noncopyable semantics.

See Also
fcppt::container::tree::release
template<typename T >
fcppt::container::tree::object< T >::holder_type const & object< T >::holder ( ) const

Returns a const reference to the holder type.

template<typename T >
void object< T >::insert ( iterator  _it,
unique_ptr  _ptr 
)

Inserts an element before the given iterator.

template<typename T >
void object< T >::insert ( iterator  _it,
arg_type  _value 
)

Inserts an element before the given iterator.

template<typename T >
fcppt::container::tree::object< T >::size_type object< T >::max_size ( ) const

Returns the ptr_list's max_size.

template<typename T >
fcppt::container::tree::object< T > & object< T >::operator= ( object< T > const &  _other)

Deeply assigns a tree.

See Also
tree_copying
template<typename T >
fcppt::container::tree::object< T > & object< T >::parent ( )

Returns a reference to the parent of this tree.

If has_parent is false, behaviour is undefined.

template<typename T >
fcppt::container::tree::object< T > const & object< T >::parent ( ) const

Returns a reference to the parent of this tree.

If has_parent is false, behaviour is undefined.

template<typename T >
void object< T >::parent ( object< T > &  _other)

Sets a new parent.

template<typename T >
fcppt::container::tree::object< T > * object< T >::parent_ptr ( )

Returns a pointer to the parent of this tree.

If there is no parent, it returns 0.

template<typename T >
fcppt::container::tree::object< T > const * object< T >::parent_ptr ( ) const

Returns a pointer to the parent of this tree.

If there is no parent, it returns 0.

template<typename T >
void object< T >::pop_back ( )

Removes a child from the end of the child list.

template<typename T >
void object< T >::pop_front ( )

Removes a child from the front of the child list.

template<typename T >
void object< T >::push_back ( unique_ptr  _ptr)

Inserts a new child at the end of the child list.

template<typename T >
void object< T >::push_back ( arg_type  _value)

Inserts a new child at the end of the child list.

template<typename T >
void object< T >::push_front ( unique_ptr  _ptr)

Adds a child in front of the child list.

template<typename T >
void object< T >::push_front ( arg_type  _value)

Adds a child in front of the child list.

template<typename T >
fcppt::container::tree::object< T >::reverse_iterator object< T >::rbegin ( )

Returns a reverse_iterator to the last element (if present)

template<typename T >
fcppt::container::tree::object< T >::const_reverse_iterator object< T >::rbegin ( ) const

Returns a const_reverse_iterator to the last element (if present)

template<typename T >
fcppt::container::tree::object< T >::unique_ptr object< T >::release ( iterator  _it)

Detaches the given child from the parent and returns it.

template<typename T >
fcppt::container::tree::object< T >::reverse_iterator object< T >::rend ( )

Returns a reverse_iterator to the first element (if present)

template<typename T >
fcppt::container::tree::object< T >::const_reverse_iterator object< T >::rend ( ) const

Returns a const_reverse_iterator to the first element (if present)

template<typename T >
fcppt::container::tree::object< T >::size_type object< T >::size ( ) const

Returns the number of children.

The complexity of this is O(n)

template<typename T >
void object< T >::swap ( object< T > &  _other)

Swaps with another tree.

template<typename T >
void object< T >::value ( arg_type  _value)

Sets a new value.

Depending on whether or not the tree has noncopyable semantics, this will either get a unique_ptr or T by value.

template<typename T >
fcppt::container::tree::object< T >::stored_type & object< T >::value ( )

Retrieves the tree's value.

template<typename T >
fcppt::container::tree::object< T >::stored_type const & object< T >::value ( ) const

Retrieves the tree's value.