source file of the Flower Library
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#define DICTIONARY_HH
#include "string.hh"
-#include "assoc.hh"
+#include "array.hh"
-/**
- UGH: write a String_hash template,
+#include "hash-table.hh"
- SEE:
-
- #include <search.h>
- ENTRY *hsearch(ENTRY item, ACTION action);
+unsigned int string_hash (String);
- int hcreate (unsigned nel);
- void hdestroy (void);
+template<class V>
+struct Dict_initialiser
+{
+ char *key_;
+ V value_;
+};
- (should be frobnified to allow multiple hashes)
- */
-template<class T>
-class Dictionary : public Assoc<String, T>
+
+template<class V>
+class Dictionary : public Hash_table<String, V>
{
public:
-
+ Dictionary ()
+ {
+ hash_func_ = string_hash;
+ }
+ Dictionary (Dict_initialiser<V> *p)
+ {
+ hash_func_ = string_hash;
+ for (Dict_initialiser<V> *q = p; q->key_; q++)
+ elem (q->key_) = q->value_;
+
+ }
+
+ friend class Dictionary_iter<V>;
};
+
#endif // DICTIONARY_HH