hashtable: style
[model-checker.git] / hashtable.h
index 6bf813520f505bdb6799f9e2e619510df6e1b7ed..a15265bafbe7f1b7658c4ddbcb8bcb8b6175a124 100644 (file)
@@ -109,7 +109,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift = 0, void *
 
                unsigned int index = ((_KeyInt)key) >> _Shift;
                do {
-                       index = index & capacitymask;
+                       index &= capacitymask;
                        search = &table[index];
                        if (search->key == key) {
                                search->val = val;
@@ -124,32 +124,30 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift = 0, void *
        }
 
        /** Lookup the corresponding value for the given key. */
-       _Val get(_Key key) {
+       _Val get(_Key key) const {
                struct hashlistnode<_Key, _Val> *search;
 
                unsigned int index = ((_KeyInt)key) >> _Shift;
                do {
-                       index = index&capacitymask;
+                       index &= capacitymask;
                        search = &table[index];
-                       if (search->key == key) {
+                       if (search->key == key)
                                return search->val;
-                       }
                        index++;
                } while (search->key);
                return (_Val) 0;
        }
 
        /** Check whether the table contains a value for the given key. */
-       bool contains(_Key key) {
+       bool contains(_Key key) const {
                struct hashlistnode<_Key, _Val> *search;
 
                unsigned int index = ((_KeyInt)key) >> _Shift;
                do {
-                       index = index & capacitymask;
+                       index &= capacitymask;
                        search = &table[index];
-                       if (search->key == key) {
+                       if (search->key == key)
                                return true;
-                       }
                        index++;
                } while (search->key);
                return false;
@@ -162,8 +160,8 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift = 0, void *
                unsigned int oldcapacity = capacity;
 
                if ((newtable = (struct hashlistnode<_Key, _Val> *) _calloc(newsize, sizeof(struct hashlistnode<_Key, _Val>))) == NULL) {
-                       model_print("Calloc error %s %d\n", __FILE__, __LINE__);
-                       exit(-1);
+                       model_print("calloc error %s %d\n", __FILE__, __LINE__);
+                       exit(EXIT_FAILURE);
                }
 
                table = newtable;          //Update the global hashtable upon resize()
@@ -181,7 +179,7 @@ template<typename _Key, typename _Val, typename _KeyInt, int _Shift = 0, void *
 
                        unsigned int index = ((_KeyInt)key) >> _Shift;
                        do {
-                               index = index & capacitymask;
+                               index &= capacitymask;
                                search = &table[index];
                                index++;
                        } while (search->key);