- Main Page
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes

# FbxMap< KEY_TYPE, VALUE_TYPE, KEY_COMPARE_FUNCTOR, ALLOCATOR > Class Template Reference

Search for all occurrences

## Detailed Description

### template<typename KEY_TYPE, typename VALUE_TYPE, typename KEY_COMPARE_FUNCTOR = FbxLessCompare<KEY_TYPE>, typename ALLOCATOR = FbxBaseAllocator>
class FbxMap< KEY_TYPE, VALUE_TYPE, KEY_COMPARE_FUNCTOR, ALLOCATOR >

This class implements an efficient map based on key comparison, which stores key-value pairs.

It executes insertion, deletion and query operations in O(log(n)) time.

Definition at line 1417 of file fbxmap.h.

`#include <fbxmap.h>`

List of all members.

## Classes
class | FbxKeyValuePair
| This class defines the key-value pairs used in FbxMap. More...
## Public Types
typedef VALUE_TYPE | ValueType
typedef KEY_TYPE | KeyType
typedef StorageType::RecordType | RecordType
typedef StorageType::IteratorType | Iterator
typedef StorageType::ConstIteratorType | ConstIterator
## Public Member Functions
| FbxMap ()
| Constructor.
| FbxMap (const FbxMap &pMap)
| Copy constructor.
| ~FbxMap ()
| Destructor.
void | Reserve (unsigned int pRecordCount)
| Preallocate memory.
int | GetSize () const
| Retrieve the number of key-value pairs it holds.
FbxPair< RecordType *, bool > | Insert (const KeyType &pKey, const ValueType &pValue)
| Insert a key-value pair.
int | Remove (const KeyType &pKey)
| Delete a key-value pair.
void | Clear ()
| Clear the map.
bool | Empty () const
| Query whether the map is empty.
Iterator | Begin ()
| Retrieve the begin iterator of the map.
Iterator | End ()
| Retrieve the end iterator of the map.
ConstIterator | Begin () const
| Retrieve the begin iterator of the map.
ConstIterator | End () const
| Retrieve the end iterator of the map.
const RecordType * | Find (const KeyType &pKey) const
| Query a key.
RecordType * | Find (const KeyType &pKey)
| Query a key.
const RecordType * | UpperBound (const KeyType &pKey) const
| Find the key-value pair with the smallest key greater than a specified key.
RecordType * | UpperBound (const KeyType &pKey)
| Find the key-value pair with the smallest key greater than a specified key.
ValueType & | operator[] (const KeyType &pKey)
| Retrieve the reference of the value in the key-value pairs in map.
const RecordType * | Minimum () const
| Retrieve the key-value pair which is the minimum key in map.
RecordType * | Minimum ()
| Retrieve the key-value pair which is the minimum key in map.
const RecordType * | Maximum () const
| Retrieve the key-value pair which is the maximum key in map.
RecordType * | Maximum ()
| Retrieve the key-value pair which is the maximum key in map.
## Protected Types
typedef FbxRedBlackTree < FbxKeyValuePair, KEY_COMPARE_FUNCTOR, ALLOCATOR > | StorageType
## Protected Attributes
StorageType | mTree

## Member Typedef Documentation

typedef FbxRedBlackTree<FbxKeyValuePair, KEY_COMPARE_FUNCTOR, ALLOCATOR> StorageType `[protected]`

Search for all occurrences

Definition at line 1442 of file fbxmap.h.

typedef VALUE_TYPE ValueType

Search for all occurrences

Definition at line 1448 of file fbxmap.h.

typedef KEY_TYPE KeyType

Search for all occurrences

Definition at line 1449 of file fbxmap.h.

typedef StorageType::RecordType RecordType

Search for all occurrences

Definition at line 1450 of file fbxmap.h.

typedef StorageType::IteratorType Iterator

Search for all occurrences

Definition at line 1451 of file fbxmap.h.

typedef StorageType::ConstIteratorType ConstIterator

Search for all occurrences

Definition at line 1452 of file fbxmap.h.

## Constructor & Destructor Documentation

FbxMap | ( |  | ) | `[inline]`

Constructor.

Definition at line 1455 of file fbxmap.h.

    {}

FbxMap | ( | const FbxMap< KEY_TYPE, VALUE_TYPE, KEY_COMPARE_FUNCTOR, ALLOCATOR > & | pMap | ) | `[inline]`

Copy constructor.

Parameters:

  pMap | The object to be copied.

Definition at line 1459 of file fbxmap.h.

    : mTree(pMap.mTree) {}

~FbxMap | ( |  | ) | `[inline]`

Destructor.

Definition at line 1461 of file fbxmap.h.

    {Clear();}

## Member Function Documentation

void Reserve | ( | unsigned int | pRecordCount | ) | `[inline]`

Search for all occurrences

Preallocate memory.

Parameters:

  pRecordCount | The number of elements.

Definition at line 1466 of file fbxmap.h.

        {
            mTree.Reserve(pRecordCount);
        }

int GetSize | ( |  | ) | const `[inline]`

Search for all occurrences

Retrieve the number of key-value pairs it holds.

Definition at line 1472 of file fbxmap.h.

        {
            return mTree.GetSize();
        }

FbxPair<RecordType*, bool> Insert | ( | const KeyType & | pKey,
|  | const ValueType & | pValue
| ) |  | `[inline]`

Search for all occurrences

Insert a key-value pair.

Parameters:

  pKey | The key.
  pValue | The value.

Returns:
  If the key is already present in the map, returns the existing pair and false; else returns the pointer to the new key-value and true.

Definition at line 1483 of file fbxmap.h.

        {
            return mTree.Insert(FbxKeyValuePair(pKey, pValue));
        }

int Remove | ( | const KeyType & | pKey | ) | `[inline]`

Search for all occurrences

Delete a key-value pair.

Parameters:

  pKey | The key.

Returns:
  `true` if success, `false` if key is not found.

Definition at line 1492 of file fbxmap.h.

        {
            return mTree.Remove(pKey);
        }

void Clear | ( |  | ) | `[inline]`

Search for all occurrences

Clear the map.

Definition at line 1498 of file fbxmap.h.

        {
            mTree.Clear();
        }

bool Empty | ( |  | ) | const `[inline]`

Search for all occurrences

Query whether the map is empty.

Definition at line 1504 of file fbxmap.h.

        {
            return mTree.Empty();
        }

Iterator Begin | ( |  | ) | `[inline]`

Search for all occurrences

Retrieve the begin iterator of the map.

Definition at line 1510 of file fbxmap.h.

        {
            return Iterator(Minimum());
        }

Iterator End | ( |  | ) | `[inline]`

Search for all occurrences

Retrieve the end iterator of the map.

Definition at line 1516 of file fbxmap.h.

        {
            return Iterator();
        }

ConstIterator Begin | ( |  | ) | const `[inline]`

Search for all occurrences

Retrieve the begin iterator of the map.

Definition at line 1522 of file fbxmap.h.

        {
            return ConstIterator(Minimum());
        }

ConstIterator End | ( |  | ) | const `[inline]`

Search for all occurrences

Retrieve the end iterator of the map.

Definition at line 1528 of file fbxmap.h.

        {
            return ConstIterator();
        }

const RecordType* Find | ( | const KeyType & | pKey | ) | const `[inline]`

Search for all occurrences

Query a key.

Parameters:

  pKey | The key.

Returns:
  A key-value pair if success, NULL if the key is not found.

Definition at line 1537 of file fbxmap.h.

        {
            return mTree.Find(pKey);
        }

RecordType* Find | ( | const KeyType & | pKey | ) | `[inline]`

Search for all occurrences

Query a key.

Parameters:

  pKey | The key.

Returns:
  A key-value pair if success, NULL if it's not found.

Definition at line 1546 of file fbxmap.h.

        {
            return mTree.Find(pKey);
        }

const RecordType* UpperBound | ( | const KeyType & | pKey | ) | const `[inline]`

Search for all occurrences

Find the key-value pair with the smallest key greater than a specified key.

Parameters:

  pKey | The key.

Returns:
  The found key-value pair.

Definition at line 1555 of file fbxmap.h.

        {
            return mTree.UpperBound(pKey);
        }

RecordType* UpperBound | ( | const KeyType & | pKey | ) | `[inline]`

Search for all occurrences

Find the key-value pair with the smallest key greater than a specified key.

Parameters:

  pKey | The key.

Returns:
  The found key-value pair.

Definition at line 1564 of file fbxmap.h.

        {
            return mTree.UpperBound(pKey);
        }

ValueType& operator[] | ( | const KeyType & | pKey | ) | `[inline]`

Retrieve the reference of the value in the key-value pairs in map.

Parameters:

  pKey | The key.

Returns:
  The reference of the value.

Remarks:
  If the key is not found, a new key-value pair will be inserted.

Definition at line 1574 of file fbxmap.h.

        {
            RecordType* lRecord = Find(pKey);

            if( !lRecord )
            {
                lRecord = Insert(pKey, ValueType()).mFirst;
            }

            return lRecord->GetValue();
        }

const RecordType* Minimum | ( |  | ) | const `[inline]`

Search for all occurrences

Retrieve the key-value pair which is the minimum key in map.

Definition at line 1587 of file fbxmap.h.

        {
            return mTree.Minimum();
        }

RecordType* Minimum | ( |  | ) | `[inline]`

Search for all occurrences

Retrieve the key-value pair which is the minimum key in map.

Definition at line 1593 of file fbxmap.h.

        {
            return mTree.Minimum();
        }

const RecordType* Maximum | ( |  | ) | const `[inline]`

Search for all occurrences

Retrieve the key-value pair which is the maximum key in map.

Definition at line 1599 of file fbxmap.h.

        {
            return mTree.Maximum();
        }

RecordType* Maximum | ( |  | ) | `[inline]`

Search for all occurrences

Retrieve the key-value pair which is the maximum key in map.

Definition at line 1605 of file fbxmap.h.

        {
            return mTree.Maximum();
        }

## Member Data Documentation

StorageType mTree `[protected]`

Search for all occurrences

Definition at line 1443 of file fbxmap.h.

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

- fbxsdk/core/base/fbxmap.h