Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class TKey>
- class KHashTableIterator : public std::iterator<std::forward_iterator_tag, KHashTable<TKey> >
- {
- friend class KHashTable<TKey>;
- protected:
- KHashTable<TKey>& data;
- int ind;
- public:
- KHashTableIterator<TKey>(KHashTable<TKey> &d, int i) : data(d), ind(i) {};
- TKey& operator *(){
- return data.table[ind];
- }
- KHashTableIterator<TKey>& operator ++(){
- ind++;
- while (!isUsed[ind])
- ind++;
- return *this;
- }
- KHashTableIterator<TKey>& operator ++(int a){
- ind++;
- while (!data.isUsed[ind])
- ind++;
- return *this;
- }
- bool operator ==(KHashTableIterator<TKey> &it){
- return (data == it.data && ind == it.ind);
- }
- bool operator !=(KHashTableIterator<TKey>&it){
- return !(*this == it);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement