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.
#include <fbxmap.h>
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. | |
typedef FbxRedBlackTree<KeyValuePair, Compare, Allocator> StorageType [protected] |
Declaration of the storage type used by the map.
| typedef Type ValueType |
| typedef Key KeyType |
| typedef StorageType::RecordType RecordType |
| typedef StorageType::IteratorType Iterator |
| void Reserve | ( | unsigned int | pRecordCount | ) | [inline] |
| int GetSize | ( | ) | const [inline] |
| FbxPair<RecordType*, bool> Insert | ( | const KeyType & | pKey, |
| const ValueType & | pValue | ||
| ) | [inline] |
Insert a key-value pair.
| pKey | The key. |
| pValue | The value. |
Definition at line 119 of file fbxmap.h.
{
return mTree.Insert(KeyValuePair(pKey, pValue));
}
| int Remove | ( | const KeyType & | pKey | ) | [inline] |
| bool Empty | ( | ) | const [inline] |
| Iterator Begin | ( | ) | [inline] |
Retrieve the begin iterator of the map.
| Iterator End | ( | ) | [inline] |
| ConstIterator Begin | ( | ) | const [inline] |
Retrieve the begin iterator of the map.
Definition at line 157 of file fbxmap.h.
{
return ConstIterator(Minimum());
}
| ConstIterator End | ( | ) | const [inline] |
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] |
| RecordType* Find | ( | const KeyType & | pKey | ) | [inline] |
| const RecordType* UpperBound | ( | const KeyType & | pKey | ) | const [inline] |
Find the key-value pair with the smallest key greater than a specified key.
| pKey | The key. |
Definition at line 187 of file fbxmap.h.
{
return mTree.UpperBound(pKey);
}
| RecordType* UpperBound | ( | const KeyType & | pKey | ) | [inline] |
Find the key-value pair with the smallest key greater than a specified key.
| pKey | The key. |
Definition at line 195 of file fbxmap.h.
{
return mTree.UpperBound(pKey);
}
Retrieve the reference of the value in the key-value pairs in map.
| pKey | The key. |
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] |
| RecordType* Minimum | ( | ) | [inline] |
| const RecordType* Maximum | ( | ) | const [inline] |
| RecordType* Maximum | ( | ) | [inline] |