- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Protected Types

# FbxMap< Key, Type, Compare, Allocator > Class Template Reference

Search for all occurrences

## Detailed Description

### template<typename Key, typename Type, typename Compare = FbxLessCompare<Key>, typename Allocator = FbxBaseAllocator>
class FbxMap< Key, Type, Compare, 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 68 of file fbxmap.h.

`#include <fbxmap.h>`

List of all members.

## Classes
class | KeyValuePair
| This class defines the key-value pairs used by the map. More...
## Public Types
typedef Type | ValueType
typedef Key | KeyType
typedef StorageType::RecordType | RecordType
typedef StorageType::IteratorType | Iterator
typedef StorageType::ConstIteratorType | ConstIterator
## Public Member Functions
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.
| FbxMap ()
| FbxMap (const FbxMap &pMap)
| ~FbxMap ()
## Protected Types
typedef FbxRedBlackTree < KeyValuePair, Compare, Allocator > | StorageType
| Declaration of the storage type used by the map.

## Member Typedef Documentation

typedef FbxRedBlackTree<KeyValuePair, Compare, Allocator> StorageType`[protected]`

Search for all occurrences

Declaration of the storage type used by the map.

Definition at line 93 of file fbxmap.h.

typedef Type ValueType

Search for all occurrences

Definition at line 96 of file fbxmap.h.

typedef Key KeyType

Search for all occurrences

Definition at line 97 of file fbxmap.h.

typedef StorageType::RecordType RecordType

Search for all occurrences

Definition at line 98 of file fbxmap.h.

typedef StorageType::IteratorType Iterator

Search for all occurrences

Definition at line 99 of file fbxmap.h.

typedef StorageType::ConstIteratorType ConstIterator

Search for all occurrences

Definition at line 100 of file fbxmap.h.

## Constructor & Destructor Documentation

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

Definition at line 244 of file fbxmap.h.

    {}

FbxMap | ( | const FbxMap< Key, Type, Compare, Allocator > & | pMap | ) | `[inline]`

Definition at line 245 of file fbxmap.h.

    : mTree(pMap.mTree){}

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

Definition at line 246 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 104 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 110 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 119 of file fbxmap.h.

        {
            return mTree.Insert(KeyValuePair(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 127 of file fbxmap.h.

        {
            return mTree.Remove(pKey);
        }

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

Search for all occurrences

Clear the map.

Definition at line 133 of file fbxmap.h.

        {
            mTree.Clear();
        }

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

Search for all occurrences

Query whether the map is empty.

Definition at line 139 of file fbxmap.h.

        {
            return mTree.Empty();
        }

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

Search for all occurrences

Retrieve the begin iterator of the map.

Definition at line 145 of file fbxmap.h.

        {
            return Iterator(Minimum());
        }

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

Search for all occurrences

Retrieve the end iterator of the map.

Definition at line 151 of file fbxmap.h.

        {
            return Iterator();
        }

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

Search for all occurrences

Retrieve the begin iterator of the map.

Definition at line 157 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 163 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 171 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 179 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 187 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 195 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 204 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 217 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 223 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 229 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 235 of file fbxmap.h.

        {
            return mTree.Maximum();
        }

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

- fbxsdk/core/base/fbxmap.h