Tree::PrivateNode< T > Class Template Reference

#include <NTree.hpp>

List of all members.


Detailed Description

template<class T>
class Tree::PrivateNode< T >

The node in the tree.


Public Types

typedef PrivateChildIterator<
T > 
ChildIterator
typedef PrivateIterator< T > Iterator

Public Member Functions

void appendChild (PrivateNode *node) throw ()
 Append a child at end of child list.
template<typename Obj, typename Process>
bool applyOnChildrenData (const Obj &instance, const Process &method, bool applyInChildren) throw ()
 Apply a method on all sub nodes in from this node.
template<typename Obj, typename Process>
bool applyOnChildrenDataLevel (const Obj &instance, const Process &method, const uint32 startLevel=0) throw ()
 Apply a method on all sub nodes in from this node.
template<typename Obj, typename Process>
bool applyOnChildrenNode (const Obj &instance, const Process &method, bool applyInChildren) throw ()
 Apply a method on all sub nodes in from this node.
PrivateNodechildAtIndex (uint32 index) const throw ()
 Get the child at the given 0-based index.
bool deleteChildAtIndex (uint32 index) throw ()
 Delete the child at the given 0-based index.
void deleteChildren () throw ()
 Delete all children.
template<typename Obj, typename Process>
PrivateNodefindChild (const Obj &instance, const Process &method, bool searchInChildren) const throw ()
 Find a child given the comparison object.
const uint32 findChildIndex (const T lookFor) const throw ()
 Find the child's index for the given data (data must support == operator).
PrivateNodefirstChild () const throw ()
 Get the first child.
PrivateNodeforgetChildAtIndex (uint32 index) throw ()
 Forget a child (this is long operation that mutate many children).
Iterator getAllIterator () const
 Get an iterator that doesn't enter children.
ChildIterator getChildIterator (const uint32 startLevel=0) const
 Get an iterator entering children.
const uint32 getChildrenCount () const throw ()
 Get the current children count.
const T & getData () const throw ()
 Get the node's internal data.
T & getData () throw ()
 Get the node's internal data.
void insertChildBefore (PrivateNode *node, uint32 index=0) throw ()
 Insert a child just before the given position.
PrivateNodelastChild () const throw ()
 Get the last child in the list This method iterate over all child, so it is better if the result is cached.
PrivateNodenextNode () const throw ()
 Get the next node at same level.
PrivateNodeparentNode () const throw ()
 Get the parent node.
 PrivateNode (const T &_data, PrivateNode *root=0, const DeleterObject< T > &xDO=getDefaultDeleterInstance())
 Constructor.
void Suicide ()
 Allow deletion using our own deleter.
 ~PrivateNode ()
 Destructor.

Friends

class NTree< T >
class PrivateChildIterator< T >
class PrivateIterator< T >


Member Typedef Documentation

template<class T>
typedef PrivateChildIterator<T> Tree::PrivateNode< T >::ChildIterator

template<class T>
typedef PrivateIterator<T> Tree::PrivateNode< T >::Iterator


Constructor & Destructor Documentation

template<class T>
Tree::PrivateNode< T >::PrivateNode ( const T &  _data,
PrivateNode< T > *  root = 0,
const DeleterObject< T > &  xDO = getDefaultDeleterInstance() 
) [inline]

Constructor.

template<class T>
Tree::PrivateNode< T >::~PrivateNode (  )  [inline]

Destructor.


Member Function Documentation

template<class T>
void Tree::PrivateNode< T >::appendChild ( PrivateNode< T > *  node  )  throw () [inline]

Append a child at end of child list.

Parameters:
node the PrivateNode to add

template<class T>
template<typename Obj, typename Process>
bool Tree::PrivateNode< T >::applyOnChildrenData ( const Obj &  instance,
const Process &  method,
bool  applyInChildren 
) throw () [inline]

Apply a method on all sub nodes in from this node.

Parameters:
instance The instance of the function object to apply
method The method of the function object to call. This method mustn't throw and return 0 on error. Its signature must be int (T ).
applyInChildren Does the function should go inside children too ?
Warning:
The method uses iterators so it shouldn't overflow stack
                // If you have
                struct A { int DoSomeWork(T & node); };
                // You can call the findChild like this
                A a;
                rootNode->applyOnChildrenData(a, &A::DoSomeWork, true);

Returns:
true on success or false

template<class T>
template<typename Obj, typename Process>
bool Tree::PrivateNode< T >::applyOnChildrenDataLevel ( const Obj &  instance,
const Process &  method,
const uint32  startLevel = 0 
) throw () [inline]

Apply a method on all sub nodes in from this node.

Parameters:
instance The instance of the function object to apply
method The method of the function object to call. This method mustn't throw and return 0 on error. Its signature must be int (T, int).
startLevel The offset to add to the level number while calling the method
Warning:
The method uses iterators so it shouldn't overflow stack
                // If you have
                struct A { int DoSomeWork(T & node, int Level); };
                // You can call the findChild like this
                A a;
                rootNode->applyOnChildrenDataLevel(a, &A::DoSomeWork);

Returns:
true on success or false

template<class T>
template<typename Obj, typename Process>
bool Tree::PrivateNode< T >::applyOnChildrenNode ( const Obj &  instance,
const Process &  method,
bool  applyInChildren 
) throw () [inline]

Apply a method on all sub nodes in from this node.

Parameters:
instance The instance of the function object to apply
method The method of the function object to call. This method mustn't throw and return 0 on error. Its signature must be int (const PrivateNode *).
applyInChildren Does the function should go inside children too ?
Warning:
The method uses iterators so it shouldn't overflow stack
                // If you have
                struct A { int DoSomeWork(const Tree::NTree<Type>::PrivateNode * node); };
                // You can call the findChild like this
                A a;
                rootNode->applyOnChildrenNode(a, &A::DoSomeWork, true);

Returns:
true on success or false

template<class T>
PrivateNode* Tree::PrivateNode< T >::childAtIndex ( uint32  index  )  const throw () [inline]

Get the child at the given 0-based index.

Parameters:
index the child's index
Returns:
the child PrivateNode pointer of 0 if not found

template<class T>
bool Tree::PrivateNode< T >::deleteChildAtIndex ( uint32  index  )  throw () [inline]

Delete the child at the given 0-based index.

Parameters:
index the child's index
Returns:
true if found and deleted, false else

template<class T>
void Tree::PrivateNode< T >::deleteChildren (  )  throw () [inline]

Delete all children.

template<class T>
template<typename Obj, typename Process>
PrivateNode* Tree::PrivateNode< T >::findChild ( const Obj &  instance,
const Process &  method,
bool  searchInChildren 
) const throw () [inline]

Find a child given the comparison object.

Parameters:
instance The instance of the comparison object to apply
method The method of the comparison object to call. This method must return 1 if found, 0 otherwise. Its signature must be "int (const T &)".
searchInChildren Does the search should go inside children too ?
Warning:
The search is recursive if entering children's list so for very large document, a stack overflow might occur
                // If you have
                struct A { int TestIfOk(const Type & data); };
                // You can call the findChild like this
                A a;
                Tree::NTree<Type>::PrivateNode * node = rootNode->findChild(a, &A::TestIfOk, true);

Returns:
the found PrivateNode pointer on success or 0

template<class T>
const uint32 Tree::PrivateNode< T >::findChildIndex ( const T  lookFor  )  const throw () [inline]

Find the child's index for the given data (data must support == operator).

Parameters:
lookFor the data to search
Returns:
i the child's index or childrenCount if not found

template<class T>
PrivateNode* Tree::PrivateNode< T >::firstChild (  )  const throw () [inline]

Get the first child.

Returns:
0 if none, or child's node pointer else

template<class T>
PrivateNode* Tree::PrivateNode< T >::forgetChildAtIndex ( uint32  index  )  throw () [inline]

Forget a child (this is long operation that mutate many children).

Warning:
This method doesn't delete the 'forgotten' child, but returns it instead (it's up to the caller to delete it)
Parameters:
index the child index to forget
              // If the child list is like  A B C D E F G
              // And forget child is called like 
              node->forgetChildAtIndex(2);
              // Then the output child list will be A B D E F G 
Returns:
the 'forgotten' child

template<class T>
Iterator Tree::PrivateNode< T >::getAllIterator (  )  const [inline]

Get an iterator that doesn't enter children.

Returns:
Iterator

template<class T>
ChildIterator Tree::PrivateNode< T >::getChildIterator ( const uint32  startLevel = 0  )  const [inline]

Get an iterator entering children.

Returns:
ChildIterator

template<class T>
const uint32 Tree::PrivateNode< T >::getChildrenCount (  )  const throw () [inline]

Get the current children count.

Returns:
the current number of children

template<class T>
const T& Tree::PrivateNode< T >::getData (  )  const throw () [inline]

Get the node's internal data.

Returns:
a reference on internal PrivateNode data

template<class T>
T& Tree::PrivateNode< T >::getData (  )  throw () [inline]

Get the node's internal data.

Returns:
a reference on internal PrivateNode data

template<class T>
void Tree::PrivateNode< T >::insertChildBefore ( PrivateNode< T > *  node,
uint32  index = 0 
) throw () [inline]

Insert a child just before the given position.

Parameters:
index the index to insert before (if not present, insert at first)
node the PrivateNode to add

template<class T>
PrivateNode* Tree::PrivateNode< T >::lastChild (  )  const throw () [inline]

Get the last child in the list This method iterate over all child, so it is better if the result is cached.

Returns:
the last child PrivateNode pointer or 0 if no child

template<class T>
PrivateNode* Tree::PrivateNode< T >::nextNode (  )  const throw () [inline]

Get the next node at same level.

Returns:
0 if none, or next node pointer else

template<class T>
PrivateNode* Tree::PrivateNode< T >::parentNode (  )  const throw () [inline]

Get the parent node.

Returns:
0 if root node, or parent's node pointer else

template<class T>
void Tree::PrivateNode< T >::Suicide (  )  [inline]

Allow deletion using our own deleter.


Friends And Related Function Documentation

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

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

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


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

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is