FreeLing
4.0
|
STL-like container implementing a n-ary tree. More...
#include <tree.h>
Public Types | |
typedef tree_preorder_iterator< T > | preorder_iterator |
iterator types for tree<T> | |
typedef const_tree_preorder_iterator < T > | const_preorder_iterator |
typedef tree_sibling_iterator< T > | sibling_iterator |
typedef const_tree_sibling_iterator< T > | const_sibling_iterator |
typedef preorder_iterator | iterator |
default tree iterator is preorder | |
typedef const_preorder_iterator | const_iterator |
Public Member Functions | |
tree () | |
constuctor | |
tree (const T &) | |
Constructor, given one element. | |
tree (const const_iterator &) | |
Constructor, given one iterator. | |
tree (const tree< T > &) | |
copy | |
tree< T > & | operator= (const tree< T > &) |
assignment | |
~tree () | |
destructor | |
void | clear () |
clear tree content | |
bool | is_root () const |
check whether the node is the root of the tree (that is, it has no further parent above) | |
bool | empty () const |
check whether the tree is empty (no nodes) | |
unsigned int | num_children () const |
number of children of the tree | |
bool | has_ancestor (const tree< T > &) const |
see if the tree is somewhere under given tree | |
sibling_iterator | nth_child (unsigned int) |
get iterator to n-th children (or end() if not there) | |
const_sibling_iterator | nth_child (unsigned int) const |
const version of nth_child | |
tree< T > & | nth_child_ref (unsigned int) |
get reference to n-th child (or end() if not there) | |
const tree< T > & | nth_child_ref (unsigned int) const |
const version of nth_child_ref | |
void | add_child (const tree< T > &t, bool last=true) |
copy given tree and add it as a child | |
void | hang_child (tree< T > &t, tree_sibling_iterator< T > where=tree_sibling_iterator< T >(NULL)) |
add given tree and as a child reordering structure. NO COPIES MADE. | |
void | hang_child (preorder_iterator &p, tree_sibling_iterator< T > where=tree_sibling_iterator< T >(NULL)) |
void | hang_child (sibling_iterator &p, tree_sibling_iterator< T > where=tree_sibling_iterator< T >(NULL)) |
preorder_iterator | get_parent () |
get iterator to parent node | |
const_preorder_iterator | get_parent () const |
get iterator to parent node | |
preorder_iterator | begin () |
Get iterator to first node in the tree. | |
preorder_iterator | end () |
Get end of iterator chain. | |
const_preorder_iterator | begin () const |
Get iterator to first node in the tree. | |
const_preorder_iterator | end () const |
Get end of iterator chain. | |
sibling_iterator | sibling_begin () |
Get iterator to first node in the tree. | |
sibling_iterator | sibling_end () |
Get end of iterator chain. | |
const_sibling_iterator | sibling_begin () const |
Get iterator to first node in the tree. | |
const_sibling_iterator | sibling_end () const |
Get end of iterator chain. | |
sibling_iterator | sibling_rbegin () |
Get iterator to last node in the tree. | |
sibling_iterator | sibling_rend () |
Get end of iterator chain. | |
const_sibling_iterator | sibling_rbegin () const |
Get iterator to first last in the tree. | |
const_sibling_iterator | sibling_rend () const |
Get end of iterator chain. | |
Static Public Member Functions | |
static const_iterator | get_leftmost_leaf (const_iterator) |
get iterator to leftmost leaf subsumed by this tree | |
static const_iterator | get_rightmost_leaf (const_iterator) |
get iterator to rightmost leaf subsumed by this tree | |
Protected Attributes | |
T * | pinfo |
information contained in the root node | |
tree< T > * | parent |
parent node | |
tree< T > * | first |
first/last child | |
tree< T > * | last |
tree< T > * | prev |
prev/next sibling | |
tree< T > * | next |
unsigned int | nchildren |
number of children | |
Private Member Functions | |
void | clone (const tree< T > &) |
auxiliary to copy, assignment, and destructor | |
Friends | |
class | basic_nonconst_tree_iterator< T > |
iterators are friends of the tree, so they can access the structure | |
class | basic_tree_iterator< T, tree< T > > |
class | basic_tree_iterator< T, const tree< T > > |
class | basic_sibling_iterator< T, basic_nonconst_tree_iterator< T > > |
class | basic_sibling_iterator< T, basic_const_tree_iterator< T > > |
class | basic_preorder_iterator< T, basic_nonconst_tree_iterator< T > > |
class | basic_preorder_iterator< T, basic_const_tree_iterator< T > > |
STL-like container implementing a n-ary tree.
typedef const_preorder_iterator freeling::tree< T >::const_iterator |
typedef const_tree_preorder_iterator<T> freeling::tree< T >::const_preorder_iterator |
typedef const_tree_sibling_iterator<T> freeling::tree< T >::const_sibling_iterator |
typedef preorder_iterator freeling::tree< T >::iterator |
default tree iterator is preorder
typedef tree_preorder_iterator<T> freeling::tree< T >::preorder_iterator |
iterator types for tree<T>
typedef tree_sibling_iterator<T> freeling::tree< T >::sibling_iterator |
freeling::tree< T >::tree | ( | ) |
constuctor
Constructor.
Empty tree (pinfo==NULL)
freeling::tree< T >::tree | ( | const T & | x | ) |
Constructor, given one element.
freeling::tree< T >::tree | ( | const const_iterator & | p | ) |
Constructor, given one iterator.
References freeling::basic_tree_iterator< T, N >::tr.
freeling::tree< T >::tree | ( | const tree< T > & | t | ) |
copy
Copy constructor.
freeling::tree< T >::~tree | ( | ) |
destructor
Destructor.
void freeling::tree< T >::add_child | ( | const tree< T > & | t, |
bool | last = true |
||
) |
copy given tree and add it as a child
tree< T >::preorder_iterator freeling::tree< T >::begin | ( | ) |
Get iterator to first node in the tree.
tree< T >::const_preorder_iterator freeling::tree< T >::begin | ( | ) | const |
Get iterator to first node in the tree.
void freeling::tree< T >::clear | ( | ) |
void freeling::tree< T >::clone | ( | const tree< T > & | t | ) | [private] |
auxiliary to copy, assignment, and destructor
Auxiliary for copy and assignment.
References freeling::tree< T >::empty(), freeling::tree< T >::first, and freeling::tree< T >::pinfo.
bool freeling::tree< T >::empty | ( | ) | const |
check whether the tree is empty (no nodes)
Check whether the tree is empty.
Referenced by freeling::tree< T >::clone().
tree< T >::preorder_iterator freeling::tree< T >::end | ( | ) |
Get end of iterator chain.
tree< T >::const_preorder_iterator freeling::tree< T >::end | ( | ) | const |
Get end of iterator chain.
tree< T >::const_iterator freeling::tree< T >::get_leftmost_leaf | ( | const_iterator | ) | [static] |
get iterator to leftmost leaf subsumed by this tree
References freeling::basic_tree_iterator< T, N >::num_children(), and freeling::basic_tree_iterator< T, N >::sibling_begin().
tree< T >::preorder_iterator freeling::tree< T >::get_parent | ( | ) |
get iterator to parent node
tree< T >::const_preorder_iterator freeling::tree< T >::get_parent | ( | ) | const |
get iterator to parent node
tree< T >::const_iterator freeling::tree< T >::get_rightmost_leaf | ( | const_iterator | ) | [static] |
get iterator to rightmost leaf subsumed by this tree
References freeling::basic_tree_iterator< T, N >::num_children(), and freeling::basic_tree_iterator< T, N >::sibling_rbegin().
void freeling::tree< T >::hang_child | ( | tree< T > & | t, |
tree_sibling_iterator< T > | where = tree_sibling_iterator< T >(NULL) |
||
) |
add given tree and as a child reordering structure. NO COPIES MADE.
void freeling::tree< T >::hang_child | ( | preorder_iterator & | p, |
tree_sibling_iterator< T > | where = tree_sibling_iterator< T >(NULL) |
||
) |
void freeling::tree< T >::hang_child | ( | sibling_iterator & | p, |
tree_sibling_iterator< T > | where = tree_sibling_iterator< T >(NULL) |
||
) |
bool freeling::tree< T >::has_ancestor | ( | const tree< T > & | p | ) | const |
see if the tree is somewhere under given tree
References freeling::tree< T >::is_root(), and freeling::tree< T >::parent.
bool freeling::tree< T >::is_root | ( | ) | const |
check whether the node is the root of the tree (that is, it has no further parent above)
Check whether the tree top has no parent (is the root.
Referenced by freeling::tree< T >::has_ancestor().
tree< T >::sibling_iterator freeling::tree< T >::nth_child | ( | unsigned int | n | ) |
get iterator to n-th children (or end() if not there)
tree< T >::const_sibling_iterator freeling::tree< T >::nth_child | ( | unsigned int | n | ) | const |
const version of nth_child
tree< T > & freeling::tree< T >::nth_child_ref | ( | unsigned int | n | ) |
get reference to n-th child (or end() if not there)
const tree< T > & freeling::tree< T >::nth_child_ref | ( | unsigned int | n | ) | const |
const version of nth_child_ref
References freeling::basic_tree_iterator< T, N >::tr.
unsigned int freeling::tree< T >::num_children | ( | ) | const |
number of children of the tree
get number of children of the tree
tree< T > & freeling::tree< T >::operator= | ( | const tree< T > & | t | ) |
assignment
Assignment.
tree< T >::sibling_iterator freeling::tree< T >::sibling_begin | ( | ) |
Get iterator to first node in the tree.
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_begin | ( | ) | const |
Get iterator to first node in the tree.
tree< T >::sibling_iterator freeling::tree< T >::sibling_end | ( | ) |
Get end of iterator chain.
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_end | ( | ) | const |
Get end of iterator chain.
tree< T >::sibling_iterator freeling::tree< T >::sibling_rbegin | ( | ) |
Get iterator to last node in the tree.
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_rbegin | ( | ) | const |
Get iterator to first last in the tree.
tree< T >::sibling_iterator freeling::tree< T >::sibling_rend | ( | ) |
Get end of iterator chain.
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_rend | ( | ) | const |
Get end of iterator chain.
friend class basic_nonconst_tree_iterator< T > [friend] |
iterators are friends of the tree, so they can access the structure
friend class basic_preorder_iterator< T, basic_const_tree_iterator< T > > [friend] |
friend class basic_preorder_iterator< T, basic_nonconst_tree_iterator< T > > [friend] |
friend class basic_sibling_iterator< T, basic_const_tree_iterator< T > > [friend] |
friend class basic_sibling_iterator< T, basic_nonconst_tree_iterator< T > > [friend] |
friend class basic_tree_iterator< T, const tree< T > > [friend] |
friend class basic_tree_iterator< T, tree< T > > [friend] |
tree<T>* freeling::tree< T >::first [protected] |
first/last child
Referenced by freeling::tree< T >::clone().
tree<T> * freeling::tree< T >::last [protected] |
unsigned int freeling::tree< T >::nchildren [protected] |
number of children
tree<T> * freeling::tree< T >::next [protected] |
Referenced by freeling::tree< T >::clear().
tree<T>* freeling::tree< T >::parent [protected] |
parent node
Referenced by freeling::tree< T >::has_ancestor().
T* freeling::tree< T >::pinfo [protected] |
information contained in the root node
Referenced by freeling::tree< T >::clone().
tree<T>* freeling::tree< T >::prev [protected] |
prev/next sibling