template<typename _Key, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
class Hashset;
-template<typename _Key, typename _KeyInt = uintptr_t, int _Shift = 0, unsigned int (*hash_function)(_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals)(_Key, _Key) = defaultEquals<_Key> >
+template<typename _Key, typename _Val, typename _KeyInt = uintptr_t, int _Shift = 0, unsigned int (*hash_function)(_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals)(_Key, _Key) = defaultEquals<_Key> >
class SetIterator {
public:
- SetIterator(Hashlistnode<_Key, _Key> *_curr, Hashtable <_Key, _Key, _KeyInt, _Shift, hash_function, equals> *_table) :
+ SetIterator(Hashlistnode<_Key, _Val> *_curr, Hashtable <_Key, _Val, _KeyInt, _Shift, hash_function, equals> *_table) :
curr(_curr),
table(_table)
{
}
private:
- Hashlistnode<_Key,_Key> *curr;
- Hashlistnode<_Key, _Key> *last;
- Hashtable <_Key, _Key, _KeyInt, _Shift, hash_function, equals> *table;
+ Hashlistnode<_Key,_Val> *curr;
+ Hashlistnode<_Key, _Val> *last;
+ Hashtable <_Key, _Val, _KeyInt, _Shift, hash_function, equals> *table;
};
template<typename _Key, typename _KeyInt = uintptr_t, int _Shift = 0, unsigned int (*hash_function)(_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals)(_Key, _Key) = defaultEquals<_Key> >
Hashset<_Key, _KeyInt, _Shift, hash_function, equals> *copy() {
Hashset<_Key, _KeyInt, _Shift, hash_function, equals> *copy = new Hashset<_Key, _KeyInt, _Shift, hash_function, equals>(table->getCapacity(), table->getLoadFactor());
- SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> *it = iterator();
+ SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *it = iterator();
while (it->hasNext())
copy->add(it->next());
delete it;
* is already present. */
void addAll(Hashset<_Key, _KeyInt, _Shift, hash_function, equals> *table) {
- SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> *it = iterator();
+ SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *it = iterator();
while (it->hasNext())
add(it->next());
delete it;
return size() == 0;
}
- SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> *iterator() {
- return new SetIterator<_Key, _KeyInt, _Shift, hash_function, equals>(table->list, table);
+SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals> *iterator() {
+ return new SetIterator<_Key, _Key, _KeyInt, _Shift, hash_function, equals>(table->list, table);
}
/** Override: new operator */
};
template<typename _Key, typename _Val, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
-SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> *getKeyIterator(Hashtable<_Key,_Val,_KeyInt,_Shift,hash_function,equals> *table) {
- return new SetIterator<_Key, _KeyInt, _Shift, hash_function, equals>(table->list, table);
+ SetIterator<_Key, _Val ,_KeyInt, _Shift, hash_function, equals> *getKeyIterator(Hashtable<_Key,_Val,_KeyInt,_Shift,hash_function,equals> *table) {
+ return new SetIterator<_Key, _Val, _KeyInt, _Shift, hash_function, equals>(table->list, table);
}
#endif