--- parser3/src/include/pa_hash.h 2001/05/17 09:21:55 1.40 +++ parser3/src/include/pa_hash.h 2001/10/05 08:20:26 1.44 @@ -5,14 +5,13 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: pa_hash.h,v 1.40 2001/05/17 09:21:55 parser Exp $ + $Id: pa_hash.h,v 1.44 2001/10/05 08:20:26 parser Exp $ */ #ifndef PA_HASH_H #define PA_HASH_H -#include - +#include "pa_config_includes.h" #include "pa_pool.h" #include "pa_types.h" #include "pa_string.h" @@ -33,12 +32,16 @@ public: typedef void (*For_each_func)(const Key& key, Val *value, void *info); /// first_that iterator function type - typedef bool (*First_that_func)(const Key& key, Val *value, void *info); + typedef void *(*First_that_func)(const Key& key, Val *value, void *info); public: Hash(Pool& apool) : Pooled(apool) { - construct(apool); + construct_new(); + } + + Hash(const Hash& source) : Pooled(source.pool()){ + construct_copy(source); } /// useful generic hash function @@ -76,20 +79,21 @@ public: //@} /// number of elements in hash - int size() const { return used; } + int size() const { return count; } /// iterate over all not zero elements void for_each(For_each_func func, void *info=0) const; /// iterate over all elements until condition - Val* first_that(First_that_func func, void *info=0) const; + void *first_that(First_that_func func, void *info=0) const; /// remove all elements void clear(); protected: - void construct(Pool& apool); + void construct_new(); + void construct_copy(const Hash& source); private: @@ -114,6 +118,9 @@ private: /// used pairs int used; + /// stored pairs total (including those by links) + int count; + /// pair storage class Pair { friend Hash; @@ -140,7 +147,6 @@ private: private: //disabled - //Hash(Hash&) {} Hash& operator = (const Hash&) { return *this; } };