(file) Return to HashTable.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/HashTable.h between version 1.9 and 1.18

version 1.9, 2001/06/16 23:10:04 version 1.18, 2004/12/23 09:40:48
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2004////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
   // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 22 
Line 27 
 // //
 // Author: Mike Brasher (mbrasher@bmc.com) // Author: Mike Brasher (mbrasher@bmc.com)
 // //
 // Modified By:  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //                  (carolann_graves@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 31 
Line 37 
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/String.h> #include <Pegasus/Common/String.h>
   #include <Pegasus/Common/Linkage.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 52 
Line 59 
     static Uint32 hash(Uint32 x) { return x + 13; }     static Uint32 hash(Uint32 x) { return x + 13; }
 }; };
  
   /*
       Hash function object that converts to lowercase.
   
       This function can be used for hash table keys constructed from strings that
       should be treated as case insensitive (e.g. class names, namespace names,
       system names).
   
       Note: this function converts to lower case based on the process locale.
   */
   struct HashLowerCaseFunc
   {
       static Uint32 hash (const String & str)
       {
           String cpy (str);
           cpy.toLower ();
           Uint32 h = 0;
           for (Uint32 i = 0, n = cpy.size (); i < n; i++)
               h = 5 * h + cpy [i];
           return h;
       }
   };
   
 /*  This is a function object used by the HashTable to compare keys. This is /*  This is a function object used by the HashTable to compare keys. This is
     the default implementation. Others may be defined and passed in the     the default implementation. Others may be defined and passed in the
     template argument list to perform other kinds of comparisons.     template argument list to perform other kinds of comparisons.
Line 65 
Line 94 
     }     }
 }; };
  
   /*
       Equal function object that can be used by HashTable to compare keys that
       should be treated as case insensitive.
   
       This function can be used for hash table keys constructed from strings that
       should be treated as case insensitive (e.g. class names, namespace names,
       system names).
   
       Note: this function compares Strings based on the process locale.
   */
   struct EqualNoCaseFunc
   {
       static Boolean equal (const String & x, const String & y)
       {
           return (0 == String::compareNoCase (x, y));
       }
   };
   
 /*  Representation for a bucket. The HashTable class derives from this /*  Representation for a bucket. The HashTable class derives from this
     bucket to append a key and value. This base class just defines     bucket to append a key and value. This base class just defines
     the pointer to the next bucket in the chain.     the pointer to the next bucket in the chain.
Line 179 
Line 226 
         @param key void pointer to key.         @param key void pointer to key.
         @return pointer to bucket with that key or zero otherwise.         @return pointer to bucket with that key or zero otherwise.
     */     */
     const _BucketBase* lookup(Uint32 hashCode, const void* key);      const _BucketBase* lookup(Uint32 hashCode, const void* key) const;
  
     /*- Removes the bucket with the given key. This method uses the     /*- Removes the bucket with the given key. This method uses the
         _BucketBase::equal() method to compare keys.         _BucketBase::equal() method to compare keys.
Line 359 
Line 406 
         }         }
         </pre>         </pre>
  
     Note that only forward iteration is supported (no backwards iteration).      Note that only forward iteration is supported (no backwards iteration),
       AND that the hashtable MUST NOT be modified during the iteration!!!
  
     Equality of keys is determined using the EqualFunc class which is     Equality of keys is determined using the EqualFunc class which is
     the default third argument of the template argument list. A new function     the default third argument of the template argument list. A new function
Line 463 
Line 511 
         @param key key to be searched for         @param key key to be searched for
         @return true if hash table contains an entry with the given key.         @return true if hash table contains an entry with the given key.
     */     */
     Boolean contains(const K& key)      Boolean contains(const K& key) const
     {     {
         V value;         V value;
         return lookup(key, value);         return lookup(key, value);
Line 474 
Line 522 
         @param value output value.         @param value output value.
         @return true if found; false otherwise.         @return true if found; false otherwise.
     */     */
     Boolean lookup(const K& key, V& value);      Boolean lookup(const K& key, V& value) const;
  
     /** Removes the entry with the given key.     /** Removes the entry with the given key.
         @param key key of entry to be removed.         @param key key of entry to be removed.
Line 498 
Line 546 
 }; };
  
 template<class K, class V, class E, class H> template<class K, class V, class E, class H>
 inline Boolean HashTable<K, V, E, H>::lookup(const K& key, V& value)  inline Boolean HashTable<K, V, E, H>::lookup(const K& key, V& value) const
 { {
     _Bucket<K, V, E>* bucket     _Bucket<K, V, E>* bucket
         = (_Bucket<K, V, E>*)_rep.lookup(H::hash(key), &key);         = (_Bucket<K, V, E>*)_rep.lookup(H::hash(key), &key);


Legend:
Removed from v.1.9  
changed lines
  Added in v.1.18

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2