Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. template <class TKey>
  2. class KHashTableIterator : public std::iterator<std::forward_iterator_tag, KHashTable<TKey> >
  3. {
  4.     friend class KHashTable<TKey>;
  5. protected:
  6.     KHashTable<TKey>& data;
  7.     int ind;
  8. public:
  9.     KHashTableIterator<TKey>(KHashTable<TKey> &d, int i) : data(d), ind(i) {};
  10.     TKey& operator *(){
  11.         return data.table[ind];
  12.     }
  13.     KHashTableIterator<TKey>& operator ++(){
  14.         ind++;
  15.         while (!isUsed[ind])
  16.             ind++;
  17.         return *this;
  18.     }
  19.     KHashTableIterator<TKey>& operator ++(int a){
  20.         ind++;
  21.         while (!data.isUsed[ind])
  22.             ind++;
  23.         return *this;
  24.     }
  25.     bool operator ==(KHashTableIterator<TKey> &it){
  26.         return (data == it.data && ind == it.ind);
  27.     }
  28.     bool operator !=(KHashTableIterator<TKey>&it){
  29.         return !(*this == it);
  30.     }
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement