FreeLing  4.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Friends
freeling::tree< T > Class Template Reference

STL-like container implementing a n-ary tree. More...

#include <tree.h>

Inheritance diagram for freeling::tree< T >:
Inheritance graph
[legend]
Collaboration diagram for freeling::tree< T >:
Collaboration graph
[legend]

List of all members.

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 > >

Detailed Description

template<class T>
class freeling::tree< T >

STL-like container implementing a n-ary tree.


Member Typedef Documentation

template<class T>
typedef const_preorder_iterator freeling::tree< T >::const_iterator
template<class T>
typedef preorder_iterator freeling::tree< T >::iterator

default tree iterator is preorder

template<class T>
typedef tree_preorder_iterator<T> freeling::tree< T >::preorder_iterator

iterator types for tree<T>

template<class T>
typedef tree_sibling_iterator<T> freeling::tree< T >::sibling_iterator

Constructor & Destructor Documentation

template<class T >
freeling::tree< T >::tree ( )

constuctor

Constructor.

Empty tree (pinfo==NULL)

template<class T>
freeling::tree< T >::tree ( const T &  x)

Constructor, given one element.

template<class T>
freeling::tree< T >::tree ( const const_iterator p)

Constructor, given one iterator.

References freeling::basic_tree_iterator< T, N >::tr.

template<class T>
freeling::tree< T >::tree ( const tree< T > &  t)

copy

Copy constructor.

template<class T >
freeling::tree< T >::~tree ( )

destructor

Destructor.


Member Function Documentation

template<class T>
void freeling::tree< T >::add_child ( const tree< T > &  t,
bool  last = true 
)

copy given tree and add it as a child

template<class T >
tree< T >::preorder_iterator freeling::tree< T >::begin ( )

Get iterator to first node in the tree.

template<class T >
tree< T >::const_preorder_iterator freeling::tree< T >::begin ( ) const

Get iterator to first node in the tree.

template<class T >
void freeling::tree< T >::clear ( )

clear tree content

Auxiliary for destructor and asignment.

References freeling::tree< T >::next.

template<class T>
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.

template<class T >
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().

template<class T >
tree< T >::preorder_iterator freeling::tree< T >::end ( )

Get end of iterator chain.

template<class T >
tree< T >::const_preorder_iterator freeling::tree< T >::end ( ) const

Get end of iterator chain.

template<class T>
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().

template<class T >
tree< T >::preorder_iterator freeling::tree< T >::get_parent ( )

get iterator to parent node

template<class T >
tree< T >::const_preorder_iterator freeling::tree< T >::get_parent ( ) const

get iterator to parent node

template<class T>
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().

template<class T>
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.

template<class T>
void freeling::tree< T >::hang_child ( preorder_iterator p,
tree_sibling_iterator< T >  where = tree_sibling_iterator< T >(NULL) 
)
template<class T>
void freeling::tree< T >::hang_child ( sibling_iterator p,
tree_sibling_iterator< T >  where = tree_sibling_iterator< T >(NULL) 
)
template<class T>
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.

template<class T >
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().

template<class T >
tree< T >::sibling_iterator freeling::tree< T >::nth_child ( unsigned int  n)

get iterator to n-th children (or end() if not there)

template<class T >
tree< T >::const_sibling_iterator freeling::tree< T >::nth_child ( unsigned int  n) const

const version of nth_child

template<class T >
tree< T > & freeling::tree< T >::nth_child_ref ( unsigned int  n)

get reference to n-th child (or end() if not there)

template<class T >
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.

template<class T >
unsigned int freeling::tree< T >::num_children ( ) const

number of children of the tree

get number of children of the tree

template<class T>
tree< T > & freeling::tree< T >::operator= ( const tree< T > &  t)

assignment

Assignment.

template<class T >
tree< T >::sibling_iterator freeling::tree< T >::sibling_begin ( )

Get iterator to first node in the tree.

template<class T >
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_begin ( ) const

Get iterator to first node in the tree.

template<class T >
tree< T >::sibling_iterator freeling::tree< T >::sibling_end ( )

Get end of iterator chain.

template<class T >
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_end ( ) const

Get end of iterator chain.

template<class T >
tree< T >::sibling_iterator freeling::tree< T >::sibling_rbegin ( )

Get iterator to last node in the tree.

template<class T >
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_rbegin ( ) const

Get iterator to first last in the tree.

template<class T >
tree< T >::sibling_iterator freeling::tree< T >::sibling_rend ( )

Get end of iterator chain.

template<class T >
tree< T >::const_sibling_iterator freeling::tree< T >::sibling_rend ( ) const

Get end of iterator chain.


Friends And Related Function Documentation

template<class T>
friend class basic_nonconst_tree_iterator< T > [friend]

iterators are friends of the tree, so they can access the structure

template<class T>
friend class basic_preorder_iterator< T, basic_const_tree_iterator< T > > [friend]
template<class T>
friend class basic_preorder_iterator< T, basic_nonconst_tree_iterator< T > > [friend]
template<class T>
friend class basic_sibling_iterator< T, basic_const_tree_iterator< T > > [friend]
template<class T>
friend class basic_sibling_iterator< T, basic_nonconst_tree_iterator< T > > [friend]
template<class T>
friend class basic_tree_iterator< T, const tree< T > > [friend]
template<class T>
friend class basic_tree_iterator< T, tree< T > > [friend]

Member Data Documentation

template<class T>
tree<T>* freeling::tree< T >::first [protected]

first/last child

Referenced by freeling::tree< T >::clone().

template<class T>
tree<T> * freeling::tree< T >::last [protected]
template<class T>
unsigned int freeling::tree< T >::nchildren [protected]

number of children

template<class T>
tree<T> * freeling::tree< T >::next [protected]
template<class T>
tree<T>* freeling::tree< T >::parent [protected]

parent node

Referenced by freeling::tree< T >::has_ancestor().

template<class T>
T* freeling::tree< T >::pinfo [protected]

information contained in the root node

Referenced by freeling::tree< T >::clone().

template<class T>
tree<T>* freeling::tree< T >::prev [protected]

prev/next sibling


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