Diff for /parser3/src/main/Attic/pa_hash.C between versions 1.44 and 1.49

version 1.44, 2001/11/01 10:59:26 version 1.49, 2002/02/08 07:27:48
Line 1 Line 1
 /** @file  /** @file
         Parser: hash class.          Parser: hash class.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru)
   
         $Id$          $Id$
 */  */
Line 88  uint Hash::generic_code(uint aresult, co Line 88  uint Hash::generic_code(uint aresult, co
 }  }
   
 bool Hash::put(const Key& key, Val *value) {  bool Hash::put(const Key& key, Val *value) {
           if(!value)
                   return remove(key);
   
         if(full())           if(full()) 
                 expand();                  expand();
   
Line 109  bool Hash::put(const Key& key, Val *valu Line 112  bool Hash::put(const Key& key, Val *valu
         return false;          return false;
 }  }
   
 void Hash::remove(const Key& key) {  bool Hash::remove(const Key& key) {
         uint code=key.hash_code();          uint code=key.hash_code();
         uint index=code%allocated;          uint index=code%allocated;
         for(Pair **ref=&refs[index]; *ref; ref=&(*ref)->link)          for(Pair **ref=&refs[index]; *ref; ref=&(*ref)->link)
Line 117  void Hash::remove(const Key& key) { Line 120  void Hash::remove(const Key& key) {
                         // found a pair with the same key                          // found a pair with the same key
                         *ref=(*ref)->link;                          *ref=(*ref)->link;
                         --count;                          --count;
                         return;                          return true;
                 }                  }
   
           return false;
 }  }
   
 Hash::Val *Hash::get(const Key& key) const {  Hash::Val *Hash::get(const Key& key) const {
Line 146  bool Hash::put_replace(const Key& key, V Line 151  bool Hash::put_replace(const Key& key, V
 }  }
   
 bool Hash::put_dont_replace(const Key& key, Val *value) {  bool Hash::put_dont_replace(const Key& key, Val *value) {
           if(!value)
                   return remove(key);
   
         if(full())           if(full()) 
                 expand();                  expand();
   

Removed from v.1.44  
changed lines
  Added in v.1.49


E-mail: