FBX C++ API Reference
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FbxHashMap< KEY, VALUE, HASH, Destruct, Comparator >::Iterator Class Reference

#include <fbxhashmap.h>

Class Description

template<typename KEY, typename VALUE, typename HASH, class Destruct = FbxNoOpDestruct<VALUE>, class Comparator = FbxDefaultComparator<KEY>>
class FbxHashMap< KEY, VALUE, HASH, Destruct, Comparator >::Iterator

Iterate through every element in a hash map.

Definition at line 77 of file fbxhashmap.h.

Public Types

typedef ListItem ListItemType
 
typedef FbxPair< KeyType, ValueTypeKeyValuePair
 

Public Member Functions

 Iterator (const Iterator &pOther)
 Copy constructor. More...
 
 ~Iterator ()
 Destructor. More...
 
KeyValuePair operator* () const
 Used to dereference an iterator and give it a behavior more similar to a pointer. More...
 
void Next ()
 Advances the iterator to the next keyvaluepair in the hashmap. More...
 
bool operator== (const Iterator &pOther) const
 Check equivalence between two iterators. More...
 
bool operator!= (const Iterator &pOther) const
 Check inequivalence between 2 iterators. More...
 
Iteratoroperator= (const Iterator &pOther)
 Assign the current iterator to the one on the right hand side of the operator. More...
 

Friends

class FbxHashMap
 

Member Typedef Documentation

◆ ListItemType

typedef ListItem ListItemType

Definition at line 81 of file fbxhashmap.h.

◆ KeyValuePair

Definition at line 82 of file fbxhashmap.h.

Constructor & Destructor Documentation

◆ Iterator()

Iterator ( const Iterator pOther)
inline

Copy constructor.

Definition at line 87 of file fbxhashmap.h.

88  :
89  mMap( pOther.mMap ),
90  mBucketIndex( pOther.mBucketIndex ),
91  mCurrentItem( pOther.mCurrentItem )
92  {
93 
94  }

◆ ~Iterator()

~Iterator ( )
inline

Destructor.

Definition at line 99 of file fbxhashmap.h.

99 {};

Member Function Documentation

◆ operator*()

KeyValuePair operator* ( ) const
inline

Used to dereference an iterator and give it a behavior more similar to a pointer.

Returns
The KeyValuePair currently referenced by the iterator

Definition at line 105 of file fbxhashmap.h.

106  {
107  KeyValuePair lItem;
108 
109  if( mCurrentItem )
110  {
111  lItem.mFirst = mCurrentItem->mKey;
112  lItem.mSecond = mCurrentItem->mValue;
113  return lItem;
114  }
115 
116  FBX_ASSERT_NOW("Accessing out of bounds iterator");
117 
118  return lItem;
119  }
FbxPair< KeyType, ValueType > KeyValuePair
Definition: fbxhashmap.h:82

◆ Next()

void Next ( )
inline

Advances the iterator to the next keyvaluepair in the hashmap.

It does not wrap around so advancing after reaching the last element will not point back to the first one.

Definition at line 125 of file fbxhashmap.h.

126  {
127  if( !mCurrentItem )
128  return;
129 
130  if( mCurrentItem->mNext )
131  {
132  mCurrentItem = mCurrentItem->mNext;
133  return;
134  }
135  else
136  {
137  mBucketIndex++;
138  for( ; mBucketIndex < mMap->mBuckets.GetCount(); ++mBucketIndex )
139  {
140  if( mMap->mBuckets[ mBucketIndex ] )
141  {
142  mCurrentItem = mMap->mBuckets[ mBucketIndex ];
143  return;
144  }
145  }
146 
147  if( mBucketIndex >= mMap->mBuckets.GetCount() )
148  {
149  *this = mMap->End();
150  return;
151  }
152  }
153  }
Iterator End() const
Returns an iterator pointing on the last element in the map.
Definition: fbxhashmap.h:372

◆ operator==()

bool operator== ( const Iterator pOther) const
inline

Check equivalence between two iterators.

There are 3 conditions for equivalence between 2 iterators: 1) Item being referenced by the iterator must be equivalent 2) They must point at the same index 3) They must point on the same map

Returns
true if both iterators are equal, false otherwise

Definition at line 162 of file fbxhashmap.h.

163  {
164  return mCurrentItem == pOther.mCurrentItem &&
165  mBucketIndex == pOther.mBucketIndex &&
166  mMap == pOther.mMap;
167  }

◆ operator!=()

bool operator!= ( const Iterator pOther) const
inline

Check inequivalence between 2 iterators.

Please see operator== for more information.

Returns
true if both iterators are NOT equal, false if they are

Definition at line 173 of file fbxhashmap.h.

174  {
175  return !(*this == pOther);
176  }

◆ operator=()

Iterator& operator= ( const Iterator pOther)
inline

Assign the current iterator to the one on the right hand side of the operator.

After assignment they will reference the same object, at the same index, in the same map.

Returns
The new iterator

Definition at line 183 of file fbxhashmap.h.

184  {
185  this->mBucketIndex = pOther.mBucketIndex;
186  this->mMap = pOther.mMap;
187  this->mCurrentItem = pOther.mCurrentItem;
188  return *this;
189  }

Friends And Related Function Documentation

◆ FbxHashMap

friend class FbxHashMap
friend

Definition at line 206 of file fbxhashmap.h.


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