13 #ifndef _FBXSDK_CORE_BASE_HASHMAP_H_ 
   14 #define _FBXSDK_CORE_BASE_HASHMAP_H_ 
   44 template< 
typename KEY, 
typename VALUE, 
typename HASH, 
class Destruct = FbxNoOpDestruct<VALUE>, 
class Comparator = FbxDefaultComparator<KEY> >
 
   69             Destruct::DoIt(mValue);        
 
   90             mBucketIndex( pOther.mBucketIndex ),
 
   91             mCurrentItem( pOther.mCurrentItem )
 
  111                 lItem.
mFirst = mCurrentItem->mKey;
 
  112                 lItem.
mSecond = mCurrentItem->mValue;
 
  116             FBX_ASSERT_NOW(
"Accessing out of bounds iterator");
 
  130             if( mCurrentItem->mNext )
 
  132                 mCurrentItem = mCurrentItem->mNext;
 
  138                 for( ; mBucketIndex < mMap->mBuckets.GetCount(); ++mBucketIndex )
 
  140                     if( mMap->mBuckets[ mBucketIndex ] )
 
  142                         mCurrentItem = mMap->mBuckets[ mBucketIndex ];
 
  147                 if( mBucketIndex >= mMap->mBuckets.GetCount() )
 
  164             return  mCurrentItem == pOther.mCurrentItem && 
 
  165                     mBucketIndex == pOther.mBucketIndex &&
 
  175             return !(*
this == pOther);
 
  185             this->mBucketIndex = pOther.mBucketIndex;
 
  186             this->mMap = pOther.mMap;
 
  187             this->mCurrentItem = pOther.mCurrentItem;
 
  195         ListItemType* mCurrentItem;
 
  200             mBucketIndex(pBucketIndex),
 
  201             mCurrentItem(pCurrentItem)
 
  215         mBuckets.
Resize( pBucketSize );
 
  240         for( 
int i = 0; i < mBuckets.GetCount(); ++i)
 
  244                 ListItem* lNext = mBuckets[i]->mNext;
 
  247                     ListItem* lNextNext = lNext->mNext;
 
  266         unsigned int lIndex = mHashFunctor(pKey);
 
  267         lIndex = lIndex % mBuckets.GetCount();
 
  268         ListItem* lItem = mBuckets[lIndex];
 
  271             if( Comparator::CompareIt( lItem->mKey, pKey ) )
 
  273                 Iterator lIt( 
this, lIndex, lItem );
 
  276             lItem = lItem->mNext;
 
  289         unsigned int lIndex = mHashFunctor(pKey);
 
  290         lIndex = lIndex % mBuckets.GetCount();
 
  291         ListItem* lItem = mBuckets.
GetAt(lIndex);
 
  292         ListItem* lLastItem = 
NULL;
 
  296             if( lItem->mKey == pKey )
 
  299                     lLastItem->mNext = lItem->mNext;
 
  301                 if( mBuckets.
GetAt(lIndex) == lItem ) 
 
  302                     mBuckets.
SetAt(lIndex, lItem->mNext );
 
  304                 VALUE lValue = lItem->mValue;
 
  311             lItem = lItem->mNext;
 
  326         unsigned int lIndex = 0;
 
  327         Iterator lIt = InternalFind( pKey, lIndex);
 
  330             return lIt.mCurrentItem->mValue;
 
  333         lIndex = lIndex % mBuckets.GetCount();
 
  334         ListItem* lItem = FbxNew< ListItem >();
 
  338         if( !mBuckets.
GetAt(lIndex) )
 
  340             mBuckets.
SetAt(lIndex, lItem);
 
  344             lItem->mNext = mBuckets.
GetAt(lIndex);
 
  345             mBuckets.
SetAt(lIndex, lItem);
 
  348         return lItem->mValue;
 
  356         for( 
int i = 0; i < mBuckets.GetCount(); ++i )
 
  360                 Iterator lIt( 
this, i, mBuckets[i] );
 
  381     const Iterator InternalFind( 
const KeyType& pKey, 
unsigned int& pOutCalculatedIndex )
 const 
  383         pOutCalculatedIndex = mHashFunctor(pKey);
 
  384         unsigned int lIndex = pOutCalculatedIndex % mBuckets.GetCount();
 
  385         ListItem* lItem = mBuckets[lIndex];
 
  388             if( Comparator::CompareIt( lItem->mKey, pKey ) )
 
  390                 Iterator lIt( 
this, lIndex, lItem );
 
  393             lItem = lItem->mNext;
 
  404     HashFunctorType mHashFunctor;
 
FbxPair< KeyType, ValueType > KeyValuePair
 
FBX SDK environment definition. 
 
This object represents a standard hash map. 
 
Iterator(const Iterator &pOther)
Copy constructor. 
 
Iterator & operator=(const Iterator &pOther)
Assign the current iterator to the one on the right hand side of the operator. 
 
T GetAt(const int pIndex) const 
Retrieve a copy of the element at given index position in the array. 
 
void FbxDelete(T *p)
Deletion policy for pointer template classes that uses the FbxDelete() function. 
 
void Clear()
Reset the number of element to zero and free the memory allocated. 
 
void Next()
Advances the iterator to the next keyvaluepair in the hashmap. 
 
KeyValuePair operator*() const 
Used to dereference an iterator and give it a behavior more similar to a pointer. ...
 
Iterator End() const 
Returns an iterator pointing on the last element in the map. 
 
Iterate through every element in a hash map. 
 
ValueType & operator[](const KeyType &pKey)
Add or retrieve a KeyValuePair from the Hashmap. 
 
void SetAt(const int pIndex, const T &pElement)
Set the element at given position in the array. 
 
This class template holds a pair of objects. 
 
~FbxHashMap()
Clear all elements in the hash map before destroying itself. 
 
const Iterator Find(const KeyType &pKey) const 
Find an element in the hashmap. 
 
FbxHashMap()
Construct a FbxHashMap with the default maximum number of elements (30) 
 
VALUE Remove(const KEY &pKey)
Remove an element in the hashmap. 
 
bool operator!=(const Iterator &pOther) const 
Check inequivalence between 2 iterators. 
 
Second mSecond
The second object in the pair. 
 
FbxHashMap(int pBucketSize)
Construct a FbxHashMap with an user-defined maximum number of elements. 
 
bool operator==(const Iterator &pOther) const 
Check equivalence between two iterators. 
 
bool Resize(const int pSize)
Inserts or erases elements at the end such that Size() becomes pSize, increasing capacity if needed...
 
First mFirst
The first object in the pair. 
 
Iterator Start() const 
Returns an iterator pointing on the first non-null element in the map. 
 
static bool CompareIt(const T &t1, const T &t2)
 
void Clear()
Calls operator delete on all elements of the hashmap, de-allocating all memory and destroying them...