Renamed macros ASSERT() and TRESPASS() to avoid clashes with the ones from
<Debug.h>. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38617 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -49,11 +49,11 @@ All rights reserved.
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
// don't include <Debug.h>
|
// don't include <Debug.h>
|
||||||
#ifndef ASSERT
|
#ifndef _OPEN_HASH_TABLE_ASSERT
|
||||||
# define ASSERT(E) (void)0
|
# define _OPEN_HASH_TABLE_ASSERT(E) (void)0
|
||||||
#endif
|
#endif
|
||||||
#ifndef TRESPASS
|
#ifndef _OPEN_HASH_TABLE_TRESPASS
|
||||||
# define TRESPASS() (void)0
|
# define _OPEN_HASH_TABLE_TRESPASS() (void)0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
@@ -207,7 +207,7 @@ template<class Element, class ElementVec>
|
|||||||
Element *
|
Element *
|
||||||
OpenHashTable<Element, ElementVec>::FindFirst(uint32 hash) const
|
OpenHashTable<Element, ElementVec>::FindFirst(uint32 hash) const
|
||||||
{
|
{
|
||||||
ASSERT(fElementVector);
|
_OPEN_HASH_TABLE_ASSERT(fElementVector);
|
||||||
hash %= fArraySize;
|
hash %= fArraySize;
|
||||||
if (fHashArray[hash] < 0)
|
if (fHashArray[hash] < 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -255,7 +255,7 @@ template<class Element, class ElementVec>
|
|||||||
Element *
|
Element *
|
||||||
OpenHashTable<Element, ElementVec>::Add(uint32 hash)
|
OpenHashTable<Element, ElementVec>::Add(uint32 hash)
|
||||||
{
|
{
|
||||||
ASSERT(fElementVector);
|
_OPEN_HASH_TABLE_ASSERT(fElementVector);
|
||||||
_RehashIfNeeded();
|
_RehashIfNeeded();
|
||||||
hash %= fArraySize;
|
hash %= fArraySize;
|
||||||
Element *result = fElementVector->Add();
|
Element *result = fElementVector->Add();
|
||||||
@@ -275,7 +275,7 @@ OpenHashTable<Element, ElementVec>::Remove(Element *element, bool dontRehash)
|
|||||||
_RehashIfNeeded();
|
_RehashIfNeeded();
|
||||||
uint32 hash = element->Hash() % fArraySize;
|
uint32 hash = element->Hash() % fArraySize;
|
||||||
int32 next = fHashArray[hash];
|
int32 next = fHashArray[hash];
|
||||||
ASSERT(next >= 0);
|
_OPEN_HASH_TABLE_ASSERT(next >= 0);
|
||||||
|
|
||||||
if (&fElementVector->At(next) == element) {
|
if (&fElementVector->At(next) == element) {
|
||||||
fHashArray[hash] = element->fNext;
|
fHashArray[hash] = element->fNext;
|
||||||
@@ -288,7 +288,7 @@ OpenHashTable<Element, ElementVec>::Remove(Element *element, bool dontRehash)
|
|||||||
// look for an existing match in table
|
// look for an existing match in table
|
||||||
next = fElementVector->At(index).fNext;
|
next = fElementVector->At(index).fNext;
|
||||||
if (next < 0) {
|
if (next < 0) {
|
||||||
TRESPASS();
|
_OPEN_HASH_TABLE_TRESPASS();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +410,7 @@ template<class Element>
|
|||||||
Element &
|
Element &
|
||||||
OpenHashElementArray<Element>::At(int32 index)
|
OpenHashElementArray<Element>::At(int32 index)
|
||||||
{
|
{
|
||||||
ASSERT(index < fSize);
|
_OPEN_HASH_TABLE_ASSERT(index < fSize);
|
||||||
return fData[index];
|
return fData[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ template<class Element>
|
|||||||
const Element &
|
const Element &
|
||||||
OpenHashElementArray<Element>::At(int32 index) const
|
OpenHashElementArray<Element>::At(int32 index) const
|
||||||
{
|
{
|
||||||
ASSERT(index < fSize);
|
_OPEN_HASH_TABLE_ASSERT(index < fSize);
|
||||||
return fData[index];
|
return fData[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ OpenHashElementArray<Element>::Add()
|
|||||||
|
|
||||||
new (&At(index)) Element;
|
new (&At(index)) Element;
|
||||||
// call placement new to initialize the element properly
|
// call placement new to initialize the element properly
|
||||||
ASSERT(At(index).fNext == -1);
|
_OPEN_HASH_TABLE_ASSERT(At(index).fNext == -1);
|
||||||
|
|
||||||
return &At(index);
|
return &At(index);
|
||||||
}
|
}
|
||||||
@@ -499,7 +499,7 @@ OpenHashElementArray<Element>::Remove(int32 index)
|
|||||||
{
|
{
|
||||||
// delete by chaining empty elements in a single linked
|
// delete by chaining empty elements in a single linked
|
||||||
// list, reusing the next field
|
// list, reusing the next field
|
||||||
ASSERT(index < fSize);
|
_OPEN_HASH_TABLE_ASSERT(index < fSize);
|
||||||
At(index).~Element();
|
At(index).~Element();
|
||||||
// call the destructor explicitly to destroy the element
|
// call the destructor explicitly to destroy the element
|
||||||
// properly
|
// properly
|
||||||
|
|||||||
Reference in New Issue
Block a user