edits
[iotcloud.git] / version2 / src / C / hashset.h
index 2a94d9666f1842885f399dcb134eaf271441cc54..a518de651ff9343c1b8bbc3e7c08fa05af1a638e 100644 (file)
@@ -18,10 +18,10 @@ struct Linknode {
        Linknode<_Key> *next;
 };
 
-template<typename _Key, typename _KeyInt, int _Shift, unsigned int (*hash_function) (_Key), bool (*equals) (_Key, _Key)>
+template<typename _Key, typename _KeyInt, int _Shift, unsigned int (*hash_function)(_Key), bool (*equals)(_Key, _Key)>
 class Hashset;
 
-template<typename _Key, typename _KeyInt, int _Shift, unsigned int (*hash_function) (_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals) (_Key, _Key) = defaultEquals<_Key> >
+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> >
 class SetIterator {
 public:
        SetIterator(Linknode<_Key> *_curr, Hashset <_Key, _KeyInt, _Shift, hash_function, equals> *_set) :
@@ -76,7 +76,7 @@ private:
        Hashset <_Key, _KeyInt, _Shift, hash_function, equals> *set;
 };
 
-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 _KeyInt = uintptr_t, int _Shift = 0, unsigned int (*hash_function)(_Key) = defaultHashFunction<_Key, _Shift, _KeyInt>, bool (*equals)(_Key, _Key) = defaultEquals<_Key> >
 class Hashset {
 public:
        Hashset(unsigned int initialcapacity = 16, double factor = 0.5) :
@@ -162,10 +162,10 @@ public:
        /** @brief Return random key from set. */
 
        _Key getRandomElement() {
-               if (getSize() == 0)
+               if (size() == 0)
                        return NULL;
-               else if (getSize() < 6) {
-                       uint count = random() % getSize();
+               else if (size() < 6) {
+                       uint count = random() % size();
                        Linknode<_Key> *ptr = list;
                        while (count > 0) {
                                ptr = ptr->next;
@@ -216,12 +216,12 @@ public:
                return true;
        }
 
-       unsigned int getSize() const {
+       unsigned int size() const {
                return table->getSize();
        }
 
        bool isEmpty() const {
-               return getSize() == 0;
+               return size() == 0;
        }
 
        SetIterator<_Key, _KeyInt, _Shift, hash_function, equals> *iterator() {