Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. template <class TKey>
  2. class KHashTablePatternIterator : public PatternIterator<TKey>
  3. {
  4.     int usedElems;
  5.     int pos;
  6.     friend KHashTable <TKey>;
  7.     KHashTable <TKey> hashTable;
  8. public:
  9.     KHashTablePatternIterator(KHashTable<TKey> &obj) : pos (0), usedElems(0), hashTable(obj) {}
  10.     TKey next() {
  11.         while (!hashTable.isUsed[pos]) { pos++; }
  12.         TKey curElem = hashTable.table[pos];
  13.         pos++;
  14.         usedElems++;
  15.         return curElem;
  16.     }
  17.     TKey& operator* () {
  18.         while (!hashTable.isUsed[pos]) { pos++; }
  19.         return hashTable.table[pos];
  20.     }
  21.     bool hasNext() { if (usedElems == hashTable.nSize) return false; else return true; }
  22.  
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement