13 #ifndef _FBXSDK_CORE_BASE_MAP_H_
14 #define _FBXSDK_CORE_BASE_MAP_H_
60 inline int operator()(
const Type& pLeft,
const Type& pRight)
const
62 return (pLeft < pRight) ? -1 : ((pRight < pLeft) ? 1 : 0);
68 template <
typename Key,
typename Type,
typename Compare=FbxLessCompare<Key>,
typename Allocator=FbxBaseAllocator>
class FbxMap
77 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 typedef const Key ConstKeyType;
82 typedef const Type ConstValueType;
85 ConstKeyType& GetKey()
const {
return this->
mFirst; }
86 KeyType& GetKey(){
return this->
mFirst; }
87 ConstValueType& GetValue()
const {
return this->
mSecond; }
88 ValueType& GetValue(){
return this->
mSecond; }
93 typedef FbxRedBlackTree<KeyValuePair, Compare, Allocator>
StorageType;
99 typedef typename StorageType::IteratorType
Iterator;
104 inline void Reserve(
unsigned int pRecordCount)
106 mTree.Reserve(pRecordCount);
112 return mTree.GetSize();
121 return mTree.Insert(KeyValuePair(pKey, pValue));
129 return mTree.Remove(pKey);
141 return mTree.Empty();
171 inline const RecordType*
Find(
const KeyType& pKey)
const
173 return mTree.Find(pKey);
179 inline RecordType*
Find(
const KeyType& pKey)
181 return mTree.Find(pKey);
187 inline const RecordType*
UpperBound(
const KeyType& pKey)
const
189 return mTree.UpperBound(pKey);
197 return mTree.UpperBound(pKey);
206 RecordType* lRecord =
Find(pKey);
213 return lRecord->GetValue();
219 return mTree.Minimum();
225 return mTree.Minimum();
231 return mTree.Maximum();
237 return mTree.Maximum();
243 #ifndef DOXYGEN_SHOULD_SKIP_THIS
263 inline void Add(
const Key& pKey,
const Type& pValue)
265 mMap.Insert(pKey, pValue);
271 inline Iterator
Find(
const Key& pKey)
const
273 return (Iterator)mMap.Find(pKey);
279 inline Iterator
Find(
const Type& pValue)
const
281 Iterator lIterator = GetFirst();
284 if( lIterator->GetValue() == pValue )
288 lIterator = GetNext(lIterator);
297 if( pIterator ) mMap.Remove(pIterator->GetKey());
304 return (Iterator)mMap.Minimum();
310 inline Iterator
GetNext(Iterator pIterator)
const
312 return (Iterator)pIterator ? pIterator->Successor() : 0;
332 return mMap.GetSize();
338 #ifndef DOXYGEN_SHOULD_SKIP_THIS
360 return pIterator ? pIterator->GetValue() : 0;
378 FbxFree(i->GetValue());
398 i->GetValue()->Destroy();
void Remove(Iterator pIterator)
Remove an element from the map.
Iterator End()
Retrieve the end iterator of the map.
FBX SDK environment definition.
FbxObjectStringMap()
Constructor.
Iterator Begin()
Retrieve the begin iterator of the map.
A simple map class representing a dictionary-like data structure.
FbxMap< Key, Type, Compare >::RecordType * Iterator
void FbxMapDestroy(FbxMap< K, V, C, A > &pMap)
Call Destroy on each element of the map, and then clear it.
int GetCount() const
Query the count of elements in the map.
const RecordType * Find(const KeyType &pKey) const
Query a key.
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.
Iterator Find(const Key &pKey) const
Find an element with a given key.
FbxObject * Get(typename FbxSimpleMap< Type, FbxObject *, Compare >::Iterator pIterator)
Get the object contained in an element.
const RecordType * UpperBound(const KeyType &pKey) const
Find the key-value pair with the smallest key greater than a specified key.
A class that maps strings to objects with a basic string comparator.
void FbxDelete(T *p)
Deletion policy for pointer template classes that uses the FbxDelete() function.
StorageType::IteratorType Iterator
RecordType * Minimum()
Retrieve the key-value pair which is the minimum key in map.
void Add(const Key &pKey, const Type &pValue)
Add a key-value pair as an element.
Iterator GetFirst() const
Get the first element.
bool Empty() const
Query whether the map is empty.
ValueType & operator[](const KeyType &pKey)
Retrieve the reference of the value in the key-value pairs in map.
This class implements an efficient map based on key comparison, which stores key-value pairs...
Default compare functor for FbxMap and FbxSet, which assumes operator < is="" defined.="" />
The base class of most FBX objects.
RecordType * Maximum()
Retrieve the key-value pair which is the maximum key in map.
This class template holds a pair of objects.
ConstIterator End() const
Retrieve the end iterator of the map.
FbxRedBlackTree< KeyValuePair, Compare, Allocator > StorageType
Declaration of the storage type used by the map.
void Reserve(unsigned int pRecordCount)
Preallocate memory.
bool Remove(const KeyType &pKey)
Delete a key-value pair.
int operator()(const Type &pLeft, const Type &pRight) const
void Reserve(int pSize)
Reserve the space for given number elements.
StorageType::ConstIteratorType ConstIterator
Type mSecond
The second object in the pair.
RecordType * UpperBound(const KeyType &pKey)
Find the key-value pair with the smallest key greater than a specified key.
const RecordType * Minimum() const
Retrieve the key-value pair which is the minimum key in map.
Iterator GetNext(Iterator pIterator) const
Get the next element of a given element.
void FbxMapFree(FbxMap< K, V, C, A > &pMap)
Call FbxFree on each element of the map, and then clear it.
void Clear()
Clear the map.
This class template declare a simple FbxObject map.
const Key mFirst
The first object in the pair.
void Clear()
Remove all of the elements.
FbxObjectMap()
Constructor.
ConstIterator Begin() const
Retrieve the begin iterator of the map.
void FbxMapDelete(FbxMap< K, V, C, A > &pMap)
Call FbxDelete on each element of the map, and then clear it.
RecordType * Find(const KeyType &pKey)
Query a key.
Iterator Find(const Type &pValue) const
Find an element with a given value.
const RecordType * Maximum() const
Retrieve the key-value pair which is the maximum key in map.
This class defines the key-value pairs used by the map.
StorageType::RecordType RecordType