Irrlicht 3D Engine
irr::core::map< KeyType, ValueType > Class Template Reference

map template for associative arrays using a red-black tree More...

#include <irrMap.h>

Classes

class  AccessClass
 
class  ConstIterator
 Const Iterator. More...
 
class  Iterator
 Normal Iterator. More...
 
class  ParentFirstIterator
 Parent First Iterator. More...
 
class  ParentLastIterator
 Parent Last Iterator. More...
 

Public Types

typedef KeyType key_type
 
typedef RBTree< KeyType, ValueType > Node
 
typedef u32 size_type
 
typedef ValueType value_type
 

Public Member Functions

 map ()
 
 ~map ()
 
void clear ()
 Clear the entire tree. More...
 
Nodedelink (const KeyType &k)
 Removes a node from the tree and returns it. More...
 
bool empty () const
 
Nodefind (const KeyType &keyToFind) const
 
ConstIterator getConstIterator () const
 Returns a Constiterator. More...
 
Iterator getIterator () const
 Returns an iterator. More...
 
ParentFirstIterator getParentFirstIterator () const
 
ParentLastIterator getParentLastIterator () const
 
NodegetRoot () const
 
bool insert (const KeyType &keyNew, const ValueType &v)
 Inserts a new node into the tree. More...
 
_IRR_DEPRECATED_ bool isEmpty () const
 
AccessClass operator[] (const KeyType &k)
 operator [] for access to elements More...
 
bool remove (const KeyType &k)
 Removes a node from the tree and deletes it. More...
 
bool remove (Node *p)
 Removes a node from the tree and deletes it. More...
 
void set (const KeyType &k, const ValueType &v)
 Replaces the value if the key already exists, otherwise inserts a new element. More...
 
u32 size () const
 Returns the number of nodes in the tree. More...
 
void swap (map< KeyType, ValueType > &other)
 Swap the content of this map container with the content of another map. More...
 

Detailed Description

template<class KeyType, class ValueType>
class irr::core::map< KeyType, ValueType >

map template for associative arrays using a red-black tree

Definition at line 18 of file irrMap.h.

Member Typedef Documentation

◆ key_type

template<class KeyType, class ValueType>
typedef KeyType irr::core::map< KeyType, ValueType >::key_type

Definition at line 668 of file irrMap.h.

◆ Node

template<class KeyType, class ValueType>
typedef RBTree<KeyType,ValueType> irr::core::map< KeyType, ValueType >::Node

Definition at line 125 of file irrMap.h.

◆ size_type

template<class KeyType, class ValueType>
typedef u32 irr::core::map< KeyType, ValueType >::size_type

Definition at line 670 of file irrMap.h.

◆ value_type

template<class KeyType, class ValueType>
typedef ValueType irr::core::map< KeyType, ValueType >::value_type

Definition at line 669 of file irrMap.h.

Constructor & Destructor Documentation

◆ map()

template<class KeyType, class ValueType>
irr::core::map< KeyType, ValueType >::map ( )
inline

Definition at line 659 of file irrMap.h.

◆ ~map()

template<class KeyType, class ValueType>
irr::core::map< KeyType, ValueType >::~map ( )
inline

Definition at line 662 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::clear().

Member Function Documentation

◆ clear()

template<class KeyType, class ValueType>
void irr::core::map< KeyType, ValueType >::clear ( )
inline

◆ delink()

template<class KeyType, class ValueType>
Node* irr::core::map< KeyType, ValueType >::delink ( const KeyType &  k)
inline

Removes a node from the tree and returns it.

The returned node must be deleted by the user

Parameters
kthe key to remove
Returns
A pointer to the node, or 0 if not found

Definition at line 774 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::find().

◆ empty()

template<class KeyType, class ValueType>
bool irr::core::map< KeyType, ValueType >::empty ( ) const
inline

Is the tree empty?

Returns
Returns true if empty, false if not

Definition at line 878 of file irrMap.h.

Referenced by irr::core::map< KeyType, ValueType >::isEmpty().

◆ find()

template<class KeyType, class ValueType>
Node* irr::core::map< KeyType, ValueType >::find ( const KeyType &  keyToFind) const
inline

Search for a node with the specified key.

Parameters
keyToFindThe key to find
Returns
Returns 0 if node couldn't be found.

Definition at line 892 of file irrMap.h.

Referenced by irr::core::map< KeyType, ValueType >::delink(), irr::core::map< KeyType, ValueType >::AccessClass::operator ValueType(), irr::core::map< KeyType, ValueType >::remove(), and irr::core::map< KeyType, ValueType >::set().

◆ getConstIterator()

template<class KeyType, class ValueType>
ConstIterator irr::core::map< KeyType, ValueType >::getConstIterator ( ) const
inline

Returns a Constiterator.

Definition at line 948 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::getRoot().

◆ getIterator()

template<class KeyType, class ValueType>
Iterator irr::core::map< KeyType, ValueType >::getIterator ( ) const
inline

Returns an iterator.

Definition at line 941 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::getRoot().

◆ getParentFirstIterator()

template<class KeyType, class ValueType>
ParentFirstIterator irr::core::map< KeyType, ValueType >::getParentFirstIterator ( ) const
inline

Returns a ParentFirstIterator. Traverses the tree from top to bottom. Typical usage is when storing the tree structure, because when reading it later (and inserting elements) the tree structure will be the same.

Definition at line 959 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::getRoot().

◆ getParentLastIterator()

template<class KeyType, class ValueType>
ParentLastIterator irr::core::map< KeyType, ValueType >::getParentLastIterator ( ) const
inline

Returns a ParentLastIterator to traverse the tree from bottom to top. Typical usage is when deleting all elements in the tree because you must delete the children before you delete their parent.

Definition at line 970 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::getRoot().

Referenced by irr::core::map< KeyType, ValueType >::clear().

◆ getRoot()

template<class KeyType, class ValueType>
Node* irr::core::map< KeyType, ValueType >::getRoot ( ) const
inline

◆ insert()

template<class KeyType, class ValueType>
bool irr::core::map< KeyType, ValueType >::insert ( const KeyType &  keyNew,
const ValueType &  v 
)
inline

Inserts a new node into the tree.

Parameters
keyNewthe index for this value
vthe value to insert
Returns
True if successful, false if it fails (already exists)

Definition at line 680 of file irrMap.h.

Referenced by irr::core::map< KeyType, ValueType >::set().

◆ isEmpty()

template<class KeyType, class ValueType>
_IRR_DEPRECATED_ bool irr::core::map< KeyType, ValueType >::isEmpty ( ) const
inline
Deprecated:
Use empty() instead. This method may be removed by Irrlicht 1.9

Definition at line 884 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::empty().

◆ operator[]()

template<class KeyType, class ValueType>
AccessClass irr::core::map< KeyType, ValueType >::operator[] ( const KeyType &  k)
inline

operator [] for access to elements

for example myMap["key"]

Definition at line 982 of file irrMap.h.

◆ remove() [1/2]

template<class KeyType, class ValueType>
bool irr::core::map< KeyType, ValueType >::remove ( const KeyType &  k)
inline

Removes a node from the tree and deletes it.

Returns
True if the node was found and deleted

Definition at line 813 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::find().

◆ remove() [2/2]

template<class KeyType, class ValueType>
bool irr::core::map< KeyType, ValueType >::remove ( Node p)
inline

Removes a node from the tree and deletes it.

Returns
True if the node was found and deleted

Definition at line 821 of file irrMap.h.

◆ set()

template<class KeyType, class ValueType>
void irr::core::map< KeyType, ValueType >::set ( const KeyType &  k,
const ValueType &  v 
)
inline

Replaces the value if the key already exists, otherwise inserts a new element.

Parameters
kThe index for this value
vThe new value of

Definition at line 761 of file irrMap.h.

References irr::core::map< KeyType, ValueType >::find(), and irr::core::map< KeyType, ValueType >::insert().

Referenced by irr::core::map< KeyType, ValueType >::AccessClass::operator=().

◆ size()

template<class KeyType, class ValueType>
u32 irr::core::map< KeyType, ValueType >::size ( ) const
inline

Returns the number of nodes in the tree.

Definition at line 920 of file irrMap.h.

◆ swap()

template<class KeyType, class ValueType>
void irr::core::map< KeyType, ValueType >::swap ( map< KeyType, ValueType > &  other)
inline

Swap the content of this map container with the content of another map.

Afterwards this object will contain the content of the other object and the other object will contain the content of this object. Iterators will afterwards be valid for the swapped object.

Parameters
otherSwap content with this object

Definition at line 930 of file irrMap.h.

References irr::core::swap().


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