--- parser3/src/include/pa_hash.h 2001/03/10 16:34:35 1.21 +++ parser3/src/include/pa_hash.h 2001/03/18 12:10:55 1.26 @@ -1,9 +1,9 @@ /* Parser Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan + Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_hash.h,v 1.21 2001/03/10 16:34:35 paf Exp $ + $Id: pa_hash.h,v 1.26 2001/03/18 12:10:55 paf Exp $ */ #ifndef PA_HASH_H @@ -15,16 +15,19 @@ #include "pa_types.h" #include "pa_string.h" -class Hash : virtual public Pooled { +class Hash : public Pooled { public: typedef String Key; typedef void Value; + typedef void (*Foreach_func)(const Key& key, Value *value, void *info); + public: - Hash(Pool& apool,bool) : Pooled(apool) { construct(apool, true); } - Hash(Pool& apool) : Pooled(apool) { construct(apool, false); } + Hash(Pool& apool,bool athread_safe=false) : Pooled(apool) { + construct(apool, athread_safe); + } // useful generic hash function static uint generic_code(uint aresult, const char *start, uint allocated); @@ -52,6 +55,8 @@ public: int size() { return used; } + void foreach(Foreach_func func, void *info=0); + protected: void construct(Pool& apool, bool athread_safe);