(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.19 and 1.24

version 1.19, 2005/02/05 22:59:23 version 1.24, 2008/01/15 22:14:15
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec 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 27 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Mike Brasher (mbrasher@bmc.com)  
 //  
 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company  
 //                  (carolann_graves@hp.com)  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #ifndef Pegasus_HashTable_h #ifndef Pegasus_HashTable_h
Line 39 
Line 36 
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/String.h> #include <Pegasus/Common/String.h>
   #include <Pegasus/Common/CIMObjectPath.h>
 #include <Pegasus/Common/Linkage.h> #include <Pegasus/Common/Linkage.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
Line 61 
Line 59 
     static Uint32 hash(Uint32 x) { return x + 13; }     static Uint32 hash(Uint32 x) { return x + 13; }
 }; };
  
 /*  PEGASUS_TEMPLATE_SPECIALIZATION struct HashFunc <CIMObjectPath>
     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)      static Uint32 hash (const CIMObjectPath & path)
     {     {
         String cpy (str);          return path.makeHashCode ();
         cpy.toLower ();  
         Uint32 h = 0;  
         for (Uint32 i = 0, n = cpy.size (); i < n; i++)  
             h = 5 * h + cpy [i];  
         return h;  
     }     }
 }; };
  
   //
   // Computes a hash code for a string without regard to case. For example, it
   // yields the same hash code for "AB", "ab", "Ab", and "aB".
   //
   struct PEGASUS_COMMON_LINKAGE HashLowerCaseFunc
   {
       static Uint32 hash(const String& str);
   };
   
 /*  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 96 
Line 89 
     }     }
 }; };
  
   PEGASUS_TEMPLATE_SPECIALIZATION struct EqualFunc <CIMObjectPath>
   {
       static Boolean equal (const CIMObjectPath & x, const CIMObjectPath & y)
       {
           return x.identical (y);
       }
   };
   
 /* /*
     Equal function object that can be used by HashTable to compare keys that     Equal function object that can be used by HashTable to compare keys that
     should be treated as case insensitive.     should be treated as case insensitive.
Line 149 
Line 150 
 { {
 public: public:
  
     _HashTableIteratorBase() : _first(0), _last(0), _bucket(0) { }      _HashTableIteratorBase(_BucketBase** first, _BucketBase** last);
  
     operator int() const { return _bucket != 0; }     operator int() const { return _bucket != 0; }
  
Line 157 
Line 158 
  
     _HashTableIteratorBase& operator++();     _HashTableIteratorBase& operator++();
  
     _HashTableIteratorBase(_BucketBase** first, _BucketBase** last);  
   
 protected: protected:
  
       _HashTableIteratorBase(const _HashTableIteratorBase&);
       _HashTableIteratorBase& operator=(const _HashTableIteratorBase&);
   
     _BucketBase** _first;     _BucketBase** _first;
     _BucketBase** _last;     _BucketBase** _last;
     _BucketBase* _bucket;     _BucketBase* _bucket;
Line 298 
Line 300 
 { {
 public: public:
  
     _HashTableIterator()  
         : _HashTableIteratorBase() { }  
   
     _HashTableIterator(_BucketBase** first, _BucketBase** last)     _HashTableIterator(_BucketBase** first, _BucketBase** last)
         : _HashTableIteratorBase(first, last) { }         : _HashTableIteratorBase(first, last) { }
  
Line 372 
Line 371 
     (which by the way has exactly the same effect).     (which by the way has exactly the same effect).
  
         <pre>         <pre>
         typedef HashTable&lt;String, Uint32, EqualFunc&lt;String&gt;, HashFunc&lt;String&gt;&gt; HT;          typedef HashTable&lt;String, Uint32,
               EqualFunc&lt;String&gt;, HashFunc&lt;String&gt;&gt; HT;
         </pre>         </pre>
  
     The third and forth arguments are described more in detail later.      The third and fourth arguments are described more in detail later.
  
     Then, entries may be inserted like this:     Then, entries may be inserted like this:
  


Legend:
Removed from v.1.19  
changed lines
  Added in v.1.24

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2