version 1.3, 2001/04/27 18:46:20
|
version 1.12, 2002/06/01 00:56:33
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
|
// The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// DEALINGS IN THE SOFTWARE. |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
//============================================================================== | //============================================================================== |
// | // |
|
|
{ | { |
Uint32 h = 0; | Uint32 h = 0; |
| |
for (Uint32 i = 0, n = str.getLength(); i < n; i++) |
for (Uint32 i = 0, n = str.size(); i < n; i++) |
h = 5 * h + str[i]; | h = 5 * h + str[i]; |
| |
return h; | return h; |
|
|
_BucketBase** first, | _BucketBase** first, |
_BucketBase** last) : _first(first), _last(last) | _BucketBase** last) : _first(first), _last(last) |
{ | { |
|
_bucket = 0; |
|
|
while (_first != last) | while (_first != last) |
{ | { |
if (*_first) | if (*_first) |
|
|
Uint32 i = hashCode % _numChains; | Uint32 i = hashCode % _numChains; |
_BucketBase* last = 0; | _BucketBase* last = 0; |
| |
for (_BucketBase* bucket = _chains[i]; bucket; bucket = bucket->next) |
for (_BucketBase* b = _chains[i]; b; b = b->next) |
{ | { |
if (bucket->equal(key)) |
if (b->equal(key)) |
{ | { |
delete bucket; | delete bucket; |
return false; | return false; |
} | } |
| |
last = bucket; |
last = b; |
} | } |
| |
// Insert bucket: | // Insert bucket: |
|
|
| |
const _BucketBase* _HashTableRep::lookup( | const _BucketBase* _HashTableRep::lookup( |
Uint32 hashCode, | Uint32 hashCode, |
const void* key) |
const void* key) const |
{ | { |
Uint32 i = hashCode % _numChains; | Uint32 i = hashCode % _numChains; |
| |