CCAFFEINE  0.8.8
Hashtable.h
00001 
00007 #ifndef Hashtable_seen
00008 #define Hashtable_seen
00009 
00010 namespace jcpp {
00011 
00012 
00013 //#include "jc++/jc++.h"
00014 // #include "jc++/lang/Object.h"
00015 // #include "jc++/util/Enumeration.h"
00016 // #include "jc++/util/HashEnum.h"
00017 // #include "jc++/util/HashBucket.h"
00018 
00022 class HashBucket;
00023 
00024 class Hashtable : public virtual Object {
00025 
00026 private:
00027 
00028   HashBucket **table;
00029   int table_length;
00030 
00031   float loadFactor;
00032   int numberOfKeys;
00033   int rehashLimit;
00034 
00035   Object **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(Object *key);
00049 
00050 public:
00051 
00052   Hashtable();
00053 
00054   ~Hashtable();
00055   
00056   int size();
00057   
00058   boolean isEmpty();
00059   
00061   /* DELETE */ Enumeration *keys();
00062 
00064   /* DELETE */ Enumeration *elements();
00065   
00066   boolean contains(Object *value);
00067 
00068   boolean containsKey(Object *key);
00069 
00072   /* FREE */ char **charKeysToArray(int& ka_length);
00073 
00074 
00075   Object *get(Object *key);
00076   
00077   Object *put(Object *key, Object *value);
00078   
00079   Object *remove(Object *key);
00080   
00081   void clear();
00082   
00088   Object *clone() { return 0; }
00089   
00091   /* FREE */ char *toString();
00092 
00093   boolean containsValue(Object *o);
00094 
00095 protected:
00096   void rehash(int & rehashError);
00097 
00098 };
00099 
00100 } ENDSEMI //jcpp
00101 #endif //Hashtable_seen