- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# fm::tree< KEY, DATA > Class Template Reference
[Mathematics Classes.]

An auto-balancing tree. More...

`#include <FMTree.h>`

List of all members.

## Public Member Functions
| tree ()
| Constructor.
| ~tree ()
| Destructor.
iterator | begin ()
| Retrieves the first ordered element within the tree.
const_iterator | begin () const
| See above.
iterator | end ()
| Retrieves an iterator that points just passed the last ordered element within the tree.
const_iterator | end () const
| See above.
iterator | last ()
| Retrieves the last ordered element within the tree.
const_iterator | last () const
| See above.
iterator | find (const KEY &key)
| Retrieves an existing data element using its key.
const_iterator | find (const KEY &key) const
| See above.
iterator | insert (const KEY &key, const DATA &data)
| Inserts a new data element with its key.
DATA & | operator[] (const KEY &k)
| Retrieves a data element using its key.
const DATA & | operator[] (const KEY &k) const
| See above.
void | erase (const KEY &key)
| Removes a data element from the tree.
void | erase (const iterator &it)
| Removes a data element from the tree.
bool | empty () const
| Retrieves whether the tree contains any data nodes.
size_t | size () const
| Retrieves the number of data nodes contained in the tree.
void | clear ()
| Removes all the data nodes from the tree.
tree< KEY, DATA > & | operator= (const tree< KEY, DATA > &copy)
| Copy constructor.
## Classes
class | const_iterator
| A tree constant-element iterator. More...
class | iterator
| A tree element iterator. More...
class | node

## Detailed Description

### template<class KEY, class DATA>
class fm::tree< KEY, DATA >

An auto-balancing tree.

Intentionally has an interface similar to the standard C++ tree class. It's implement should be very similar yet more lightweight.

## Member Function Documentation

template<class KEY, class DATA>
iterator fm::tree< KEY, DATA >::begin | ( |  | ) | `[inline]`

| Retrieves the first ordered element within the tree. Returns: An iterator that points to the first tree element.

template<class KEY, class DATA>
void fm::tree< KEY, DATA >::clear | ( |  | ) | `[inline]`

| Removes all the data nodes from the tree. This effectively prunes at the tree root.

template<class KEY, class DATA>
bool fm::tree< KEY, DATA >::empty | ( |  | ) | const`[inline]`

| Retrieves whether the tree contains any data nodes. Returns: Whether the tree contains any data nodes.

template<class KEY, class DATA>
iterator fm::tree< KEY, DATA >::end | ( |  | ) | `[inline]`

| Retrieves an iterator that points just passed the last ordered element within the tree. Returns: An iterator just passed the last element in the tree.

template<class KEY, class DATA>
void fm::tree< KEY, DATA >::erase | ( | const iterator & | it | ) | `[inline]`

  | Removes a data element from the tree. Parameters:
  | it | An iterator that points to the tree element to erase.

template<class KEY, class DATA>
void fm::tree< KEY, DATA >::erase | ( | const KEY & | key | ) | `[inline]`

  | Removes a data element from the tree. Parameters:
  | key | The key of the data element to erase.

template<class KEY, class DATA>
iterator fm::tree< KEY, DATA >::find | ( | const KEY & | key | ) | `[inline]`

  | Retrieves an existing data element using its key. Parameters:
  | key | The key.
Returns: An iterator that points to the existing data element. This iterator may be past the end of the tree, in the case where the key does not exists within the tree: do check the iterator against end().

template<class KEY, class DATA>
iterator fm::tree< KEY, DATA >::insert | ( | const KEY & | key,
|  | const DATA & | data
| ) | `[inline]`

  | Inserts a new data element with its key. If the key already exists within the tree, the old data element will be overwritten using the new data element. Parameters:
  | key | The new key.
  | data | The new data element.
Returns: An iterator that points to the tree element.

template<class KEY, class DATA>
iterator fm::tree< KEY, DATA >::last | ( |  | ) | `[inline]`

| Retrieves the last ordered element within the tree. Returns: An iterator that points to the last tree element.

template<class KEY, class DATA>
tree<KEY,DATA>& fm::tree< KEY, DATA >::operator= | ( | const tree< KEY, DATA > & | copy | ) | `[inline]`

  | Copy constructor. Clones another tree into this one. This is a bad function: it costs too much performance, avoid at all costs! Parameters:
  | copy | The tree to clone.
Returns: This tree, cloned.

template<class KEY, class DATA>
DATA& fm::tree< KEY, DATA >::operator[] | ( | const KEY & | k | ) | `[inline]`

  | Retrieves a data element using its key. Parameters:
  | k | The key.
Returns: The data element for this key. In the non-constant version of this function, a new element is created for the key if it does not already belong to the tree.

template<class KEY, class DATA>
size_t fm::tree< KEY, DATA >::size | ( |  | ) | const`[inline]`

| Retrieves the number of data nodes contained in the tree. Returns: The number of data nodes contained in the tree.

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

- FMath/FMTree.h