Make more defined classes visible outside the BPrivate namespace when including

this header.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35078 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-01-14 21:49:53 +00:00
parent edb41bfb71
commit 41777edb47

View File

@ -1,17 +1,17 @@
// HashMap.h // HashMap.h
// //
// Copyright (c) 2004-2007, Ingo Weinhold (bonefish@cs.tu-berlin.de) // Copyright (c) 2004-2007, Ingo Weinhold (bonefish@cs.tu-berlin.de)
// //
// 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 of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation // to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, // the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the // and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions: // Software is furnished to do so, subject to the following conditions:
// //
// The above copyright notice and this permission notice shall be included in // The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software. // all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@ -19,7 +19,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
// Except as contained in this notice, the name of a copyright holder shall // Except as contained in this notice, the name of a copyright holder shall
// not be used in advertising or otherwise to promote the sale, use or other // not be used in advertising or otherwise to promote the sale, use or other
// dealings in this Software without prior written authorization of the // dealings in this Software without prior written authorization of the
@ -88,18 +88,19 @@ public:
typedef HashMapElement<Key, Value> Element; typedef HashMapElement<Key, Value> Element;
public: public:
Iterator(const Iterator& other) Iterator(const Iterator& other)
: fMap(other.fMap), :
fIndex(other.fIndex), fMap(other.fMap),
fElement(other.fElement), fIndex(other.fIndex),
fLastElement(other.fElement) fElement(other.fElement),
fLastElement(other.fElement)
{ {
} }
bool HasNext() const bool HasNext() const
{ {
return fElement; return fElement;
} }
Entry Next() Entry Next()
{ {
if (!fElement) if (!fElement)
@ -113,7 +114,7 @@ public:
{ {
if (fElement == NULL) if (fElement == NULL)
return NULL; return NULL;
Value* value = &fElement->fValue; Value* value = &fElement->fValue;
_FindNext(); _FindNext();
return value; return value;
@ -128,7 +129,7 @@ public:
fLastElement = NULL; fLastElement = NULL;
return result; return result;
} }
Iterator& operator=(const Iterator& other) Iterator& operator=(const Iterator& other)
{ {
fMap = other.fMap; fMap = other.fMap;
@ -137,18 +138,19 @@ public:
fLastElement = other.fLastElement; fLastElement = other.fLastElement;
return *this; return *this;
} }
private: private:
Iterator(const HashMap<Key, Value>* map) Iterator(const HashMap<Key, Value>* map)
: fMap(const_cast<HashMap<Key, Value>*>(map)), :
fIndex(0), fMap(const_cast<HashMap<Key, Value>*>(map)),
fElement(NULL), fIndex(0),
fLastElement(NULL) fElement(NULL),
fLastElement(NULL)
{ {
// find first // find first
_FindNext(); _FindNext();
} }
void _FindNext() void _FindNext()
{ {
fLastElement = fElement; fLastElement = fElement;
@ -161,10 +163,10 @@ public:
for (; !fElement && fIndex < arraySize; fIndex++) for (; !fElement && fIndex < arraySize; fIndex++)
fElement = fMap->fTable.FindFirst(fIndex); fElement = fMap->fTable.FindFirst(fIndex);
} }
private: private:
friend class HashMap<Key, Value>; friend class HashMap<Key, Value>;
HashMap<Key, Value>* fMap; HashMap<Key, Value>* fMap;
int32 fIndex; int32 fIndex;
Element* fElement; Element* fElement;
@ -345,8 +347,9 @@ struct HashKey64 {
// constructor // constructor
template<typename Key, typename Value> template<typename Key, typename Value>
HashMap<Key, Value>::HashMap() HashMap<Key, Value>::HashMap()
: fElementArray(1000), :
fTable(1000, &fElementArray) fElementArray(1000),
fTable(1000, &fElementArray)
{ {
} }
@ -376,7 +379,7 @@ HashMap<Key, Value>::Put(const Key& key, Value value)
element->fValue = value; element->fValue = value;
return B_OK; return B_OK;
} }
// does not contain the key yet: add an element // does not contain the key yet: add an element
element = fTable.Add(key.GetHashCode()); element = fTable.Add(key.GetHashCode());
if (!element) if (!element)
return B_NO_MEMORY; return B_NO_MEMORY;
@ -471,5 +474,8 @@ HashMap<Key, Value>::_FindElement(const Key& key) const
} // namespace BPrivate } // namespace BPrivate
using BPrivate::HashMap; using BPrivate::HashMap;
using BPrivate::HashKey32;
using BPrivate::HashKey64;
using BPrivate::SynchronizedHashMap;
#endif // HASH_MAP_H #endif // HASH_MAP_H