More edits
[iotcloud.git] / version2 / src / C / hashset.h
index 55ae1fb12c14e152fc22f7346561c151d5bfd854..bfbb6b85d433f9c2766d6d31e7cde6bd0e650a23 100644 (file)
 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)
        {
@@ -64,9 +64,9 @@ public:
        }
 
 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> >
@@ -84,7 +84,7 @@ public:
 
        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;
@@ -99,7 +99,7 @@ public:
         *  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;
@@ -146,8 +146,8 @@ public:
                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 */
@@ -174,7 +174,7 @@ private:
 };
 
 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