Diff for /parser3/src/main/Attic/pa_hash.C between versions 1.19 and 1.29

version 1.19, 2001/03/10 16:34:39 version 1.29, 2001/03/24 10:54:46
Line 1 Line 1
 /*  /** @file
         Parser          Parser: hash class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru>  
           Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$          $Id$
 */  */
Line 14 Line 16
         For more information about Zend please visit http://www.zend.com/          For more information about Zend please visit http://www.zend.com/
 */  */
   
   #include "pa_config_includes.h"
   
 #include "pa_hash.h"  #include "pa_hash.h"
 #include "pa_threads.h"  #include "pa_threads.h"
   
Line 78  uint Hash::generic_code(uint aresult, co Line 82  uint Hash::generic_code(uint aresult, co
         return result;          return result;
 }  }
   
 bool Hash::put(const Key& key, Value *value) {  SYNCHRONIZED(thread_safe);  bool Hash::put(const Key& key, Val *value) {  SYNCHRONIZED(thread_safe);
         if(full())           if(full()) 
                 expand();                  expand();
   
Line 99  bool Hash::put(const Key& key, Value *va Line 103  bool Hash::put(const Key& key, Value *va
         return false;          return false;
 }  }
   
 Hash::Value *Hash::get(const Key& key) const {  SYNCHRONIZED(thread_safe);  Hash::Val *Hash::get(const Key& key) const {  SYNCHRONIZED(thread_safe);
         uint code=key.hash_code();          uint code=key.hash_code();
         uint index=code%allocated;          uint index=code%allocated;
         for(Pair *pair=refs[index]; pair; pair=pair->link)          for(Pair *pair=refs[index]; pair; pair=pair->link)
Line 109  Hash::Value *Hash::get(const Key& key) c Line 113  Hash::Value *Hash::get(const Key& key) c
         return 0;          return 0;
 }  }
   
 bool Hash::put_replace(const Key& key, Value *value) {  SYNCHRONIZED(thread_safe);  bool Hash::put_replace(const Key& key, Val *value) {  SYNCHRONIZED(thread_safe);
         uint code=key.hash_code();          uint code=key.hash_code();
         uint index=code%allocated;          uint index=code%allocated;
         for(Pair *pair=refs[index]; pair; pair=pair->link)          for(Pair *pair=refs[index]; pair; pair=pair->link)
Line 123  bool Hash::put_replace(const Key& key, V Line 127  bool Hash::put_replace(const Key& key, V
         return false;          return false;
 }  }
   
 bool Hash::put_dont_replace(const Key& key, Value *value) {  SYNCHRONIZED(thread_safe);  bool Hash::put_dont_replace(const Key& key, Val *value) {  SYNCHRONIZED(thread_safe);
         if(full())           if(full()) 
                 expand();                  expand();
   
Line 149  void Hash::merge_dont_replace(const Hash Line 153  void Hash::merge_dont_replace(const Hash
                         put_dont_replace(pair->key, pair->value);                          put_dont_replace(pair->key, pair->value);
         // MAY:optimize this.allocated==src.allocated case          // MAY:optimize this.allocated==src.allocated case
 }  }
   
   void Hash::for_each(For_each_func func, void *info) {
           Pair **ref=refs;
           for(int index=0; index<allocated; index++)
                   for(Pair *pair=*ref++; pair; pair=pair->link)
                           if(pair->value)
                                   (*func)(pair->key, pair->value, info);
   }
   
   void Hash::clear() {  SYNCHRONIZED(thread_safe);
           memset(refs, 0, sizeof(*refs)*allocated);
           used=0;
   }

Removed from v.1.19  
changed lines
  Added in v.1.29


E-mail: