|
|
| version 1.58.2.18.2.4, 2003/03/20 13:09:53 | version 1.58.2.18.2.7, 2003/03/27 14:05:40 |
|---|---|
| Line 40 public: | Line 40 public: |
| allocated=allocates[allocates_index=0]; | allocated=allocates[allocates_index=0]; |
| threshold=allocated*THRESHOLD_PERCENT/100; | threshold=allocated*THRESHOLD_PERCENT/100; |
| fpairs_count=fused_refs=0; | fpairs_count=fused_refs=0; |
| refs=new(0) Pair*[allocated]; | refs=new(UseGC) Pair*[allocated]; |
| } | } |
| Hash(const Hash& source) { | Hash(const Hash& source) { |
| Line 49 public: | Line 49 public: |
| threshold=source.threshold; | threshold=source.threshold; |
| fused_refs=source.fused_refs; | fused_refs=source.fused_refs; |
| fpairs_count=source.fpairs_count; | fpairs_count=source.fpairs_count; |
| refs=new(0) Pair*[allocated]; | refs=new(UseGC) Pair*[allocated]; |
| // clone & rehash | // clone & rehash |
| Pair **old_ref=source.refs; | Pair **old_ref=source.refs; |
| Line 197 public: | Line 197 public: |
| /// remove all elements | /// remove all elements |
| void clear() { | void clear() { |
| destroy_pairs(); memset(refs, 0, sizeof(*refs)*allocated); | memset(refs, 0, sizeof(*refs)*allocated); |
| fpairs_count=fused_refs=0; | fpairs_count=fused_refs=0; |
| } | } |
| Line 291 template<typename K, typename V> | Line 291 template<typename K, typename V> |
| int Hash<K, V>::allocates_count=sizeof(allocates)/sizeof(uint); | int Hash<K, V>::allocates_count=sizeof(allocates)/sizeof(uint); |
| /// useful generic hash function | /// useful generic hash function |
| inline void generic_hash_code(uint& result, char c) { | |
| result=(result<<4)+c; | |
| if(uint g=(result&0xF0000000)) { | |
| result=result^(g>>24); | |
| result=result^g; | |
| } | |
| } | |
| /// useful generic hash function | |
| inline void generic_hash_code(uint& result, const char* s) { | inline void generic_hash_code(uint& result, const char* s) { |
| while(char c=*s++) { | while(char c=*s++) { |
| result=(result<<4)+c; | result=(result<<4)+c; |