Defines the iterator type for LuaHashMap. More...
#include <LuaHashMap.h>
Defines the iterator type for LuaHashMap.
Iterators are the way to iterate through a hash table. Iterators in LuaHashMap conceptually similar to the C++ STL notion of an iterator (but much simpler).
Mental Model: LuaHashMapIterators (unlike LuaHashMap) are stack objects. No dynamic memory is required. This allows you to use iterators without worrying about freeing them when done and leaking. They are also generally seen as short term, inexpensive objects you should be able to refetch at will (an O(1) lookup by key). (But it is certainly possible to create iterators with dynamic memory and keep them around. Just watch out for them getting stale.)
Best practice is to use these structs as opaque objects. Use the API functions to retrieve values from the struct/iterators instead of direct access.
Trivia: You may notice that iterator functions that operate on the LuaHashMap instance don't require an explicit LuaHashMap instance passed into the function. This is because LuaHashMapIterator saves a copy of the LuaHashMap pointer when it was created.