#include <splaytree.h>
Public Member Functions | |
| SplayTree () | |
| The default constructor. | |
| ~SplayTree () | |
| The destructor. | |
| void | empty () |
| Empties the entire tree. | |
| bool | insert (Key const &_key, Data const &_rec) |
| Inserts data into the tree. | |
| bool | exists (Key const &_key) const |
| Tests whether a key is in the tree or not. | |
| bool | replace (Key const &_key, Data const &_rec) |
| Change the data at the given node. | |
| bool | find (Key const &_key, Data &_data) const |
| Finds a node in the tree and copies the data from that node to a specified location. | |
| Data | find (Key const &_key) const |
| Finds a node in the tree and returns the data at that node. | |
| bool | erase (Key const &_key) |
| Deletes a node from the tree, specified by the node's key. | |
| size_t | size () const |
| Indicates the size of the tree. | |
| DArray< Data > * | ConvertToDArray () const |
| Converts the tree data into a linearized DArray. | |
| DArray< Key > * | ConvertIndexToDArray () const |
| Converts the tree keys into a linearized DArray. | |
| size_t | mem_usage () const |
| Returns the overhead caused by the data structure. | |
Private Member Functions | |
| SplayTree (const SplayTree< Key, Data > &) | |
| Private copy constructor. | |
| SplayTree< Key, Data > & | operator= (const SplayTree< Key, Data > &) |
| Private assignment operator. | |
This is a tree which does NOT allow duplicate keys.
Private copy constructor.
If your code needs to invoke the copy constructor, you've probably written the code wrong. A tree copy is generally unnecessary, and in cases that it is, it can be achieved by other means.
| DArray<Key>* ConvertIndexToDArray | ( | ) | const |
| DArray<Data>* ConvertToDArray | ( | ) | const |
| void empty | ( | ) |
Empties the entire tree.
| bool erase | ( | Key const & | _key | ) |
Deletes a node from the tree, specified by the node's key.
| _key | The key of the node to delete. |
| bool exists | ( | Key const & | _key | ) | const |
Tests whether a key is in the tree or not.
| _key | The key of the node to find. |
| Data find | ( | Key const & | _key | ) | const |
Finds a node in the tree and returns the data at that node.
| _key | The key of the node to find. |
| bool find | ( | Key const & | _key, | |
| Data & | _data | |||
| ) | const |
Finds a node in the tree and copies the data from that node to a specified location.
| _key | The key of the node to find. | |
| _data | On return, will contain the data at the node. If not found, _data does not change. |
| bool insert | ( | Key const & | _key, | |
| Data const & | _rec | |||
| ) |
Inserts data into the tree.
| _key | The key of the data. | |
| _rec | The data to insert. |
| size_t mem_usage | ( | ) | const |
Returns the overhead caused by the data structure.
Private assignment operator.
If your code needs to invoke the assignment operator, you've probably written the code wrong. A tree copy is generally unnecessary, and in cases that it is, it can be achieved by other means.
| bool replace | ( | Key const & | _key, | |
| Data const & | _rec | |||
| ) |
Change the data at the given node.
| _key | The key of the node to be modified. | |
| _rec | The data to insert. |
| size_t size | ( | ) | const [inline] |
Indicates the size of the tree.
1.5.8