QxtLinkedTree Class Reference
[QxtCore module]

fast Container for tree structured data More...

 #include <QxtLinkedTree>

Public Functions

Public Static Functions


Detailed Description

this template class can be used to store data easily in a tree structure.
Internally it uses the doublelinked list scheme, but adds client/parent links.

There are no random access functions, you have to use QxtLinkedTree::iterator to access the data.
This is very fast and efficient.

QxtLinkedTree<int> tree(1);

QxtLinkedTreeIterator<int> it= tree.root();
it.append(34);
qDebug()<<it<<it.child(); //returns "1 34"

In order to be able to store an iterator into other data structures (eg. for QAbstractItemModel or QAbstractXmlNodeModel) functions are provided to create and store a linked item from and into a void pointer.

void * root= tree.toVoid(tree.root());
QxtLinkedTreeIterator<int> it= tree.fromVoid(root);

implicit shared This class is implicit shared.

Member Documentation

QxtLinkedTree ( )

constructs a QxtLinkedTree with a default constructed root node.




QxtLinkedTree ( T t )

constructs a QxtLinkedTree. sets the rootnode to t




~QxtLinkedTree ( )

the destructor deletes all items, when they are no longer referenced by any other instance.




void clear ( )

deletes all nodes recursively. this might take forever depending on the size of your tree.




QxtLinkedTreeIterator< T > root ( )

returns an iterator on the root node




QxtLinkedTreeIterator< T > fromVoid ( void * d ) static

returns an iterator pre positioned on the item specified with toVoid.
passing anything that has not beeing created by toVoid() will crash.
also note that passing invalidated nodes will crash too.
Be extremly carefull. It is easy to currupt your data with this!




void * toVoid ( QxtLinkedTreeIterator< T > n ) static

get an unique void pointer to be able to stuff an iterator into other structures.
You must not do anything else but pass this to fromVoid(). the pointer is invalid when the actual data has been removed and passing it to fromVoid will crash. You have been warned.






Copyright © 2007 Qxt Foundation Trademarks
Qt Extension Library 0.4