HashTableIterator< HASHTABLEKEY, TYPE > Class Template Reference
[Containers]
Iterator for HashTable.
More...
Public Member Functions | |
| HashTableIterator (const HashTable< HASHTABLEKEY, TYPE > &table) | |
| void | MoveFirst () |
| void | MoveNext () |
| void | MovePrevious () |
| void | MoveLast () |
| TYPE & | GetCurrent () const |
| bool | IsValid () const |
| bool | Find (const HASHTABLEKEY &key) |
| const HASHTABLEKEY & | GetCurrentKey () const |
Friends | |
| class | HashTable< HASHTABLEKEY, TYPE > |
Detailed Description
template<class HASHTABLEKEY, class TYPE>
class HashTableIterator< HASHTABLEKEY, TYPE >
Iterator for HashTable.
The iterator provides a convenient way to loop trough all the items of a hash table in the same way as you would a linked list. When created, the iterator points at the first item in the table, and you can then move it around using GetFirst, GetNext, GetLast and GetPrevious, and even search for a specific item using Find. Note that hash tables are optimized to be extremely fast when searching (using Find), but this also results in stepping through the table using GetFirst, GetNext etc. might be very slow, and it is not recommended that you do this in performance critical code. If you need fast looping through, consider using a linked list or a dynamic array instead (which are much less efficient when using Find).
Definition at line 34 of file HashTableIterator.h.
Constructor & Destructor Documentation
| HashTableIterator< HASHTABLEKEY, TYPE >::HashTableIterator | ( | const HashTable< HASHTABLEKEY, TYPE > & | table | ) |
Constructor
Definition at line 8 of file HashTableIterator.inl.
Member Function Documentation
| void HashTableIterator< HASHTABLEKEY, TYPE >::MoveFirst | ( | ) |
Returns the first item in the table, and resets the iterator to return the second item the next time GetNext is called
- Returns:
- The first item in the table
Definition at line 19 of file HashTableIterator.inl.
| void HashTableIterator< HASHTABLEKEY, TYPE >::MoveNext | ( | ) |
Returns the next item in the table, and advances the iterator
- Returns:
- The next item in the table, or 0 if there is none
Definition at line 42 of file HashTableIterator.inl.
| void HashTableIterator< HASHTABLEKEY, TYPE >::MovePrevious | ( | ) |
Returns the previous item in the table, and moves the iterator back
- Returns:
- The previous item in the table, or 0 if there is none
Definition at line 95 of file HashTableIterator.inl.
| void HashTableIterator< HASHTABLEKEY, TYPE >::MoveLast | ( | ) |
Returns the last item in the table, and resets the iterator to return the next to last item the next time GetPrevious is called
- Returns:
- The last item in the table
Definition at line 72 of file HashTableIterator.inl.
| TYPE & HashTableIterator< HASHTABLEKEY, TYPE >::GetCurrent | ( | ) | const |
Returns the item the iterator is currently pointing at
- Returns:
- The current item
Definition at line 119 of file HashTableIterator.inl.
| bool HashTableIterator< HASHTABLEKEY, TYPE >::IsValid | ( | ) | const |
Checks if the iterator have reached the end of the table
- Returns:
- True if the iterator is at the end of the table
Definition at line 139 of file HashTableIterator.inl.
| bool HashTableIterator< HASHTABLEKEY, TYPE >::Find | ( | const HASHTABLEKEY & | key | ) |
Finds an item in the table
- Returns:
- A pointer to the item, or 0 if it was not found
- Parameters:
-
key Key of item to look for
Definition at line 158 of file HashTableIterator.inl.
| const HASHTABLEKEY & HashTableIterator< HASHTABLEKEY, TYPE >::GetCurrentKey | ( | ) | const |
Gets the key of the item that the iterator is currently pointing at
- Returns:
- Key of the item the iterator is currently pointing at
Definition at line 206 of file HashTableIterator.inl.
Friends And Related Function Documentation
friend class HashTable< HASHTABLEKEY, TYPE > [friend] |
Definition at line 104 of file HashTableIterator.h.
Reproduction/republishing of any material on this site without permission is strictly prohibited.
