Rudiments
Public Member Functions | List of all members
avltree< valuetype > Class Template Reference

Inherits treecollection< valuetype >.

Public Member Functions

 avltree ()
 
 avltree (avltree< valuetype > &a)
 
 avltree (treecollection< valuetype > &a)
 
 avltree (nodecollection< valuetype > &a)
 
avltree< valuetype > & operator= (avltree< valuetype > &a)
 
avltree< valuetype > & operator= (treecollection< valuetype > &a)
 
avltree< valuetype > & operator= (nodecollection< valuetype > &a)
 
 ~avltree ()
 
void insert (valuetype value)
 
void insert (treenode< valuetype > *node)
 
treenode< valuetype > * detach (treenode< valuetype > *node)
 
bool remove (valuetype value)
 
bool removeAll (valuetype value)
 
bool remove (treenode< valuetype > *node)
 
uint64_t getCount ()
 
treenode< valuetype > * getTop ()
 
treenode< valuetype > * getFirst ()
 
treenode< valuetype > * getLast ()
 
treenode< valuetype > * getPrevious (treenode< valuetype > *node)
 
treenode< valuetype > * getNext (treenode< valuetype > *node)
 
treenode< valuetype > * find (valuetype value)
 
treenode< valuetype > * find (treenode< valuetype > *startnode, valuetype value)
 
bool clear ()
 
- Public Member Functions inherited from treecollection< valuetype >
 treecollection ()
 
 treecollection (nodecollection< valuetype > &n)
 
virtual const char * getType ()
 
virtual void insert (valuetype *value, uint64_t count)
 
virtual ssize_t write ()
 
virtual ssize_t write (output *out)
 
virtual ssize_t writeJson ()
 
virtual ssize_t writeJson (bool indent)
 
virtual ssize_t writeJson (output *out)
 
virtual ssize_t writeJson (output *out, bool indent)
 
virtual ssize_t writeXml ()
 
virtual ssize_t writeXml (bool indent)
 
virtual ssize_t writeXml (output *out)
 
virtual ssize_t writeXml (output *out, bool indent)
 
- Public Member Functions inherited from collection
 collection ()
 
 collection (collection &c)
 
collectionoperator= (collection &c)
 
virtual ~collection ()
 
comparatorgetComparator ()
 
void setComparator (comparator *newcomp)
 
virtual bool isReadOnly ()
 
virtual bool isBlockBased ()
 
virtual uint64_t getBlockSize ()
 
virtual bool isSequentialAccess ()
 
virtual void setManageValues (bool manage)
 
virtual bool getManageValues ()
 
virtual void setManageArrayValues (bool manage)
 
virtual bool getManageArrayValues ()
 
virtual void setManageKeys (bool manage)
 
virtual bool getManageKeys ()
 
virtual void setManageArrayKeys (bool manage)
 
virtual bool getManageArrayKeys ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

template<class valuetype>
class avltree< valuetype >

The avltree class allows you to store an arbitrary number of values in a self-sorting, self-balancing binary tree. Since the avltree class is template-based, you can store arbitrary types of values.

Each avltree is composed of a set of avltreenodes. Each avltreenode contains a value.

Constructor & Destructor Documentation

◆ avltree() [1/4]

template<class valuetype >
avltree< valuetype >::avltree
inline

Creates an empty instance of the avltree class.

◆ avltree() [2/4]

template<class valuetype >
avltree< valuetype >::avltree ( avltree< valuetype > &  a)
inline

Creates an instance of the avltree class that is a copy of "a".

◆ avltree() [3/4]

template<class valuetype >
avltree< valuetype >::avltree ( treecollection< valuetype > &  a)
inline

Creates an instance of the avltree class that is a copy of "a".

◆ avltree() [4/4]

template<class valuetype >
avltree< valuetype >::avltree ( nodecollection< valuetype > &  a)
inline

Creates an instance of the avltree class that is a copy of "a".

◆ ~avltree()

template<class valuetype >
avltree< valuetype >::~avltree
inline

Deletes this instance of the avltree class and all of its avltreenodes.

The value stored in each avltreenode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Member Function Documentation

◆ clear()

template<class valuetype >
bool avltree< valuetype >::clear
inlinevirtual

Deletes all avltreenodes currently in the avltree.

The value stored in each avltreenode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Always returns true.

Implements collection.

◆ detach()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::detach ( treenode< valuetype > *  node)
inlinevirtual

Detaches "node" from the tree.

Implements treecollection< valuetype >.

◆ find() [1/2]

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::find ( treenode< valuetype > *  startnode,
valuetype  value 
)
inlinevirtual

Returns a pointer to the first avltreenode below "startnode" containing "value" or NULL if "value" was not found.

Implements treecollection< valuetype >.

◆ find() [2/2]

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::find ( valuetype  value)
inlinevirtual

Returns a pointer to the first avltreenode containing "value" or NULL if "value" was not found.

Implements treecollection< valuetype >.

◆ getCount()

template<class valuetype >
uint64_t avltree< valuetype >::getCount
inlinevirtual

Returns the number of nodes in the avltree.

Implements collection.

◆ getFirst()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::getFirst
inlinevirtual

Returns the first node in the avltree (in an in-order, depth-first traversal).

Implements treecollection< valuetype >.

◆ getLast()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::getLast
inlinevirtual

Returns the last node in the avltree (in an in-order, depth-first traversal).

Implements treecollection< valuetype >.

◆ getNext()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::getNext ( treenode< valuetype > *  node)
inlinevirtual

Returns the node after "node" or NULL if this node is the last node in the tree (in an in-order, depth-first traversal). "node" is presumed to be in the tree.

Implements treecollection< valuetype >.

◆ getPrevious()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::getPrevious ( treenode< valuetype > *  node)
inlinevirtual

Returns the node prior to "node" or NULL if this node is the first node in the tree (in an in-order, depth-first traversal). "node" is presumed to be in the tree.

Implements treecollection< valuetype >.

◆ getTop()

template<class valuetype >
treenode< valuetype > * avltree< valuetype >::getTop
inlinevirtual

Returns the top-most node in the avltree.

Implements treecollection< valuetype >.

◆ insert() [1/2]

template<class valuetype >
void avltree< valuetype >::insert ( treenode< valuetype > *  node)
inlinevirtual

Inserts already created avltreenode "node" to the avltree.

Implements treecollection< valuetype >.

◆ insert() [2/2]

template<class valuetype >
void avltree< valuetype >::insert ( valuetype  value)
inlinevirtual

Creates a new avltreenode containing "value" and prepends it to the avltree.

Implements treecollection< valuetype >.

◆ operator=() [1/3]

template<class valuetype >
avltree< valuetype > & avltree< valuetype >::operator= ( avltree< valuetype > &  a)
inline

Makes this instance of the avltree class identical to "a".

◆ operator=() [2/3]

template<class valuetype >
avltree< valuetype > & avltree< valuetype >::operator= ( nodecollection< valuetype > &  a)
inline

Makes this instance of the avltree class identical to "a".

◆ operator=() [3/3]

template<class valuetype >
avltree< valuetype > & avltree< valuetype >::operator= ( treecollection< valuetype > &  a)
inline

Makes this instance of the avltree class identical to "a".

◆ remove() [1/2]

template<class valuetype >
bool avltree< valuetype >::remove ( treenode< valuetype > *  node)
inlinevirtual

Removed avltreenode "node" from the avltree.

The value stored in the avltreenode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation does not require a search and is far less expensive than the remove(value) operation and removeAll().

Returns true on success and false on failure.

Implements treecollection< valuetype >.

◆ remove() [2/2]

template<class valuetype >
bool avltree< valuetype >::remove ( valuetype  value)
inlinevirtual

Deletes the first avltreenode containing "value".

The value stored in the avltreenode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation requires a search and is expensive in both execution time and code size.

Returns true on success and false on failure.

Implements treecollection< valuetype >.

◆ removeAll()

template<class valuetype >
bool avltree< valuetype >::removeAll ( valuetype  value)
inlinevirtual

Deletes all avltreenodes containing "value".

The value stored in each avltreenode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation requires a search and is expensive in both execution time and code size.

Returns true on success and false on failure.

Implements treecollection< valuetype >.