CCAFFEINE  0.8.8
GenericHashTable.h
00001 
00007 #ifndef GenericHashTable_seen
00008 #define GenericHashTable_seen
00009 //#include "jc++/jc++.h"
00010 // #include "jc++/lang/Object.h"
00011 // #include "jc++/lang/HashKey.h"
00012 // #include "jc++/util/Enumeration.h"
00013 // #include "jc++/util/HashEnum.h"
00014 // #include "jc++/util/HashBucket.h"
00015 
00016 namespace jcpp {
00017 
00018 
00022 class HashBucket;
00023 
00024 class GenericHashTable : public virtual Object {
00025 
00026 private:
00027 
00028   GenericHashBucket **table;
00029   int table_length;
00030 
00031   float loadFactor;
00032   int numberOfKeys;
00033   int rehashLimit;
00034 
00035   HashKey **okeys; // void pointer array
00036   Object **oelements;
00037 
00040   static const long magic;
00042   int N;
00044   int ttmNm2;
00046   int twoNm1; 
00047 
00048   int calculateBucket(HashKey *key);
00049 
00050 public:
00051   
00052   GenericHashTable();
00053 
00054   ~GenericHashTable();
00055   
00056   int size();
00057   
00058   boolean isEmpty();
00059   
00061   CDELETE Enumeration *keys();
00062 
00064   CDELETE Enumeration *elements();
00065   
00066   boolean contains(Object *value);
00067 
00068   boolean containsKey(HashKey *key);
00069 
00072   CFREE char **charKeysToArray(int& ka_length);
00073 
00074 
00075   Object *get(HashKey *key);
00076   
00077   Object *put(HashKey *key, Object *value);
00078   
00079   Object *remove(HashKey *key);
00080   
00081   void clear();
00082   
00088   HashKey *clone() { return 0; }
00089   
00091   /* cfree */ char *toString();
00092 
00093   boolean containsValue(Object *o);
00094 
00095 protected:
00096   void rehash(int & rehashError);
00097 
00098 };
00099 
00100 } ENDSEMI //jcpp
00101 #endif //GenericHashTable_seen