* Removed src/kits/tracker/OpenHashTable.h. The shared version in
headers/private/shared is newer, though with small interface changes. * Removed the unnecessary Debug.h include in headers/private/shared/ObjectList.h. * Adjusted sources using these headers, mostly by adding missing includes. * Lots of automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30123 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -65,7 +65,8 @@ All rights reserved.
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
template<class T> class BObjectList;
|
template<class T> class BObjectList;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "ExtendedPartitionAddOn.h"
|
#include "ExtendedPartitionAddOn.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <DiskDeviceTypes.h>
|
#include <DiskDeviceTypes.h>
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
#include "ProbeView.h"
|
#include "ProbeView.h"
|
||||||
#include "TypeEditors.h"
|
#include "TypeEditors.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <TabView.h>
|
#include <TabView.h>
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
#include <fs_info.h>
|
#include <fs_info.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "DataView.h"
|
#include "DataView.h"
|
||||||
#include "DataEditor.h"
|
#include "DataEditor.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
# include <IconUtils.h>
|
# include <IconUtils.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -27,8 +30,6 @@
|
|||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgValueChanged = 'vlch';
|
static const uint32 kMsgValueChanged = 'vlch';
|
||||||
static const uint32 kMsgScaleChanged = 'scch';
|
static const uint32 kMsgScaleChanged = 'scch';
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
#include "PartitionList.h"
|
#include "PartitionList.h"
|
||||||
#include "Support.h"
|
#include "Support.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "Support.h"
|
#include "Support.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Partition.h>
|
#include <Partition.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <DiskDevice.h>
|
#include <DiskDevice.h>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "DiskDeviceJobQueue.h"
|
#include "DiskDeviceJobQueue.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
#include "DiskDeviceJob.h"
|
#include "DiskDeviceJob.h"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Node.h>
|
|
||||||
#include "AttributeStream.h"
|
#include "AttributeStream.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <Node.h>
|
||||||
|
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// lazy Rewind from Drive, only if data is available
|
// lazy Rewind from Drive, only if data is available
|
||||||
// BMessage node
|
// BMessage node
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ All rights reserved.
|
|||||||
|
|
||||||
#include "AutoMounter.h"
|
#include "AutoMounter.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
#include "AutoMounterSettings.h"
|
#include "AutoMounterSettings.h"
|
||||||
#include "Commands.h"
|
#include "Commands.h"
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Beep.h>
|
|
||||||
|
|
||||||
#include "FilePermissionsView.h"
|
#include "FilePermissionsView.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Beep.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kPermissionsChanged = 'prch';
|
const uint32 kPermissionsChanged = 'prch';
|
||||||
const uint32 kNewOwnerEntered = 'nwow';
|
const uint32 kNewOwnerEntered = 'nwow';
|
||||||
|
|||||||
@@ -1430,7 +1430,7 @@ SharedIconCache::AddItem(const char *fileType, const char *appSignature)
|
|||||||
if (!fileType)
|
if (!fileType)
|
||||||
fileType = B_FILE_MIMETYPE;
|
fileType = B_FILE_MIMETYPE;
|
||||||
|
|
||||||
SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
||||||
appSignature));
|
appSignature));
|
||||||
result->SetTo(fileType, appSignature);
|
result->SetTo(fileType, appSignature);
|
||||||
return result;
|
return result;
|
||||||
@@ -1448,7 +1448,7 @@ SharedIconCache::AddItem(SharedCacheEntry **outstandingEntry, const char *fileTy
|
|||||||
if (!fileType)
|
if (!fileType)
|
||||||
fileType = B_FILE_MIMETYPE;
|
fileType = B_FILE_MIMETYPE;
|
||||||
|
|
||||||
SharedCacheEntry *result = &fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
SharedCacheEntry *result = fHashTable.Add(SharedCacheEntry::Hash(fileType,
|
||||||
appSignature));
|
appSignature));
|
||||||
result->SetTo(fileType, appSignature);
|
result->SetTo(fileType, appSignature);
|
||||||
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
||||||
@@ -1593,7 +1593,7 @@ SharedCacheEntryArray::SharedCacheEntryArray(int32 initialSize)
|
|||||||
SharedCacheEntry *
|
SharedCacheEntry *
|
||||||
SharedCacheEntryArray::Add()
|
SharedCacheEntryArray::Add()
|
||||||
{
|
{
|
||||||
return &At(OpenHashElementArray<SharedCacheEntry>::Add());
|
return OpenHashElementArray<SharedCacheEntry>::Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1775,7 +1775,7 @@ NodeIconCache::FindItem(const node_ref *node) const
|
|||||||
NodeCacheEntry *
|
NodeCacheEntry *
|
||||||
NodeIconCache::AddItem(const node_ref *node, bool permanent)
|
NodeIconCache::AddItem(const node_ref *node, bool permanent)
|
||||||
{
|
{
|
||||||
NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node));
|
NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node));
|
||||||
result->SetTo(node);
|
result->SetTo(node);
|
||||||
if (permanent)
|
if (permanent)
|
||||||
result->MakePermanent();
|
result->MakePermanent();
|
||||||
@@ -1789,7 +1789,7 @@ NodeIconCache::AddItem(NodeCacheEntry **outstandingEntry, const node_ref *node)
|
|||||||
{
|
{
|
||||||
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
|
int32 entryToken = fHashTable.ElementIndex(*outstandingEntry);
|
||||||
|
|
||||||
NodeCacheEntry *result = &fHashTable.Add(NodeCacheEntry::Hash(node));
|
NodeCacheEntry *result = fHashTable.Add(NodeCacheEntry::Hash(node));
|
||||||
result->SetTo(node);
|
result->SetTo(node);
|
||||||
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
*outstandingEntry = fHashTable.ElementAt(entryToken);
|
||||||
|
|
||||||
@@ -1861,7 +1861,7 @@ NodeCacheEntryArray::NodeCacheEntryArray(int32 initialSize)
|
|||||||
NodeCacheEntry *
|
NodeCacheEntry *
|
||||||
NodeCacheEntryArray::Add()
|
NodeCacheEntryArray::Add()
|
||||||
{
|
{
|
||||||
return &At(OpenHashElementArray<NodeCacheEntry>::Add());
|
return OpenHashElementArray<NodeCacheEntry>::Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ All rights reserved.
|
|||||||
|
|
||||||
// MountMenu implements a context menu used for mounting/unmounting volumes
|
// MountMenu implements a context menu used for mounting/unmounting volumes
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|||||||
@@ -1,376 +0,0 @@
|
|||||||
/*
|
|
||||||
Open Tracker License
|
|
||||||
|
|
||||||
Terms and Conditions
|
|
||||||
|
|
||||||
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, 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:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice applies to all licensees
|
|
||||||
and shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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 DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
Except as contained in this notice, the name of Be Incorporated shall not be
|
|
||||||
used in advertising or otherwise to promote the sale, use or other dealings in
|
|
||||||
this Software without prior written authorization from Be Incorporated.
|
|
||||||
|
|
||||||
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
|
||||||
of Be Incorporated in the United States and other countries. Other brand product
|
|
||||||
names are registered trademarks or trademarks of their respective holders.
|
|
||||||
All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Hash table with open addresssing
|
|
||||||
|
|
||||||
#ifndef __OPEN_HASH_TABLE__
|
|
||||||
#define __OPEN_HASH_TABLE__
|
|
||||||
|
|
||||||
#include <new>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
|
|
||||||
template <class Element>
|
|
||||||
class ElementVector {
|
|
||||||
// element vector for OpenHashTable needs to implement this
|
|
||||||
// interface
|
|
||||||
public:
|
|
||||||
Element &At(int32 index);
|
|
||||||
Element *Add();
|
|
||||||
int32 IndexOf(const Element &) const;
|
|
||||||
void Remove(int32 index);
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenHashElement {
|
|
||||||
public:
|
|
||||||
uint32 Hash() const;
|
|
||||||
bool operator==(const OpenHashElement &) const;
|
|
||||||
void Adopt(OpenHashElement &);
|
|
||||||
// low overhead copy, original element is in undefined state
|
|
||||||
// after call (calls Adopt on BString members, etc.)
|
|
||||||
int32 fNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint32 kPrimes [] = {
|
|
||||||
509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139,
|
|
||||||
524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859,
|
|
||||||
134217689, 268435399, 536870909, 1073741789, 2147483647, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class Element, class ElementVec = ElementVector<Element> >
|
|
||||||
class OpenHashTable {
|
|
||||||
public:
|
|
||||||
OpenHashTable(int32 minSize, ElementVec *elementVector = 0);
|
|
||||||
// it is up to the subclass of OpenHashTable to supply
|
|
||||||
// elementVector
|
|
||||||
~OpenHashTable();
|
|
||||||
|
|
||||||
void SetElementVector(ElementVec *elementVector);
|
|
||||||
|
|
||||||
Element *FindFirst(uint32 elementHash) const;
|
|
||||||
Element &Add(uint32 elementHash);
|
|
||||||
|
|
||||||
void Remove(Element *);
|
|
||||||
|
|
||||||
// when calling Add, any outstanding element pointer may become
|
|
||||||
// invalid; to deal with this, get the element index and restore
|
|
||||||
// it after the add
|
|
||||||
int32 ElementIndex(const Element *) const;
|
|
||||||
Element *ElementAt(int32 index) const;
|
|
||||||
|
|
||||||
int32 VectorSize() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static int32 OptimalSize(int32 minSize);
|
|
||||||
|
|
||||||
int32 fArraySize;
|
|
||||||
int32 *fHashArray;
|
|
||||||
ElementVec *fElementVector;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template <class Element>
|
|
||||||
class OpenHashElementArray : public ElementVector<Element> {
|
|
||||||
// this is a straightforward implementation of an element vector
|
|
||||||
// deleting is handled by linking deleted elements into a free list
|
|
||||||
// the vector never shrinks
|
|
||||||
public:
|
|
||||||
OpenHashElementArray(int32 initialSize);
|
|
||||||
~OpenHashElementArray();
|
|
||||||
|
|
||||||
Element &At(int32 index);
|
|
||||||
const Element &At(int32 index) const;
|
|
||||||
int32 Add(const Element &);
|
|
||||||
int32 Add();
|
|
||||||
void Remove(int32 index);
|
|
||||||
int32 IndexOf(const Element &) const;
|
|
||||||
int32 Size() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Element *fData;
|
|
||||||
int32 fSize;
|
|
||||||
int32 fNextFree;
|
|
||||||
int32 fNextDeleted;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//--- inline implementation --------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
OpenHashTable<Element, ElementVec>::OpenHashTable(int32 minSize,ElementVec *elementVector)
|
|
||||||
:
|
|
||||||
fArraySize(OptimalSize(minSize)),
|
|
||||||
fElementVector(elementVector)
|
|
||||||
{
|
|
||||||
fHashArray = new int32[fArraySize];
|
|
||||||
for (int32 index = 0; index < fArraySize; index++)
|
|
||||||
fHashArray[index] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
OpenHashTable<Element, ElementVec>::~OpenHashTable()
|
|
||||||
{
|
|
||||||
delete fHashArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::OptimalSize(int32 minSize)
|
|
||||||
{
|
|
||||||
for (int32 index = 0; ; index++)
|
|
||||||
if (!kPrimes[index] || kPrimes[index] >= (uint32)minSize)
|
|
||||||
return (int32)kPrimes[index];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element *
|
|
||||||
OpenHashTable<Element, ElementVec>::FindFirst(uint32 hash) const
|
|
||||||
{
|
|
||||||
ASSERT(fElementVector);
|
|
||||||
hash %= fArraySize;
|
|
||||||
if (fHashArray[hash] < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return &fElementVector->At(fHashArray[hash]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::ElementIndex(const Element *element) const
|
|
||||||
{
|
|
||||||
return fElementVector->IndexOf(*element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element *
|
|
||||||
OpenHashTable<Element, ElementVec>::ElementAt(int32 index) const
|
|
||||||
{
|
|
||||||
return &fElementVector->At(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
int32
|
|
||||||
OpenHashTable<Element, ElementVec>::VectorSize() const
|
|
||||||
{
|
|
||||||
return fElementVector->Size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
Element &
|
|
||||||
OpenHashTable<Element, ElementVec>::Add(uint32 hash)
|
|
||||||
{
|
|
||||||
ASSERT(fElementVector);
|
|
||||||
hash %= fArraySize;
|
|
||||||
Element &result = *fElementVector->Add();
|
|
||||||
result.fNext = fHashArray[hash];
|
|
||||||
fHashArray[hash] = fElementVector->IndexOf(result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
void
|
|
||||||
OpenHashTable<Element, ElementVec>::Remove(Element *element)
|
|
||||||
{
|
|
||||||
uint32 hash = element->Hash() % fArraySize;
|
|
||||||
int32 next = fHashArray[hash];
|
|
||||||
ASSERT(next >= 0);
|
|
||||||
|
|
||||||
if (&fElementVector->At(next) == element) {
|
|
||||||
fHashArray[hash] = element->fNext;
|
|
||||||
fElementVector->Remove(next);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32 index = next; index >= 0; ) {
|
|
||||||
// look for an existing match in table
|
|
||||||
int32 next = fElementVector->At(index).fNext;
|
|
||||||
if (next < 0) {
|
|
||||||
TRESPASS();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (&fElementVector->At(next) == element) {
|
|
||||||
fElementVector->At(index).fNext = element->fNext;
|
|
||||||
fElementVector->Remove(next);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
index = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element, class ElementVec>
|
|
||||||
void
|
|
||||||
OpenHashTable<Element, ElementVec>::SetElementVector(ElementVec *elementVector)
|
|
||||||
{
|
|
||||||
fElementVector = elementVector;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
OpenHashElementArray<Element>::OpenHashElementArray(int32 initialSize)
|
|
||||||
:
|
|
||||||
fSize(initialSize),
|
|
||||||
fNextFree(0),
|
|
||||||
fNextDeleted(-1)
|
|
||||||
{
|
|
||||||
fData = (Element *)calloc((size_t)initialSize , sizeof(Element));
|
|
||||||
if (!fData)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
OpenHashElementArray<Element>::~OpenHashElementArray()
|
|
||||||
{
|
|
||||||
free(fData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
Element &
|
|
||||||
OpenHashElementArray<Element>::At(int32 index)
|
|
||||||
{
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
return fData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
const Element &
|
|
||||||
OpenHashElementArray<Element>::At(int32 index) const
|
|
||||||
{
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
return fData[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::IndexOf(const Element &element) const
|
|
||||||
{
|
|
||||||
int32 result = &element - fData;
|
|
||||||
if (result < 0 || result > fSize)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Size() const
|
|
||||||
{
|
|
||||||
return fSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Add(const Element &newElement)
|
|
||||||
{
|
|
||||||
int32 index = Add();
|
|
||||||
At(index).Adopt(newElement);
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
const int32 kGrowChunk = 10;
|
|
||||||
#else
|
|
||||||
const int32 kGrowChunk = 1024;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
int32
|
|
||||||
OpenHashElementArray<Element>::Add()
|
|
||||||
{
|
|
||||||
int32 index = fNextFree;
|
|
||||||
if (fNextDeleted >= 0) {
|
|
||||||
index = fNextDeleted;
|
|
||||||
fNextDeleted = At(index).fNext;
|
|
||||||
} else if (fNextFree >= fSize - 1) {
|
|
||||||
int32 newSize = fSize + kGrowChunk;
|
|
||||||
Element *newData = (Element *)calloc((size_t)newSize , sizeof(Element));
|
|
||||||
if (!newData)
|
|
||||||
throw std::bad_alloc();
|
|
||||||
memcpy(newData, fData, fSize * sizeof(Element));
|
|
||||||
free(fData);
|
|
||||||
fData = newData;
|
|
||||||
fSize = newSize;
|
|
||||||
index = fNextFree;
|
|
||||||
fNextFree++;
|
|
||||||
} else
|
|
||||||
fNextFree++;
|
|
||||||
|
|
||||||
new (&At(index)) Element;
|
|
||||||
// call placement new to initialize the element properly
|
|
||||||
ASSERT(At(index).fNext == -1);
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Element>
|
|
||||||
void
|
|
||||||
OpenHashElementArray<Element>::Remove(int32 index)
|
|
||||||
{
|
|
||||||
// delete by chaining empty elements in a single linked
|
|
||||||
// list, reusing the next field
|
|
||||||
ASSERT(index < fSize);
|
|
||||||
At(index).~Element();
|
|
||||||
// call the destructor explicitly to destroy the element
|
|
||||||
// properly
|
|
||||||
At(index).fNext = fNextDeleted;
|
|
||||||
fNextDeleted = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -32,6 +32,7 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
#include "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ All rights reserved.
|
|||||||
#ifndef __THREAD__
|
#ifndef __THREAD__
|
||||||
#define __THREAD__
|
#define __THREAD__
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
#include "FunctionObject.h"
|
#include "FunctionObject.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "TrackerSettings.h"
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
#include "Tracker.h"
|
#include "Tracker.h"
|
||||||
#include "TrackerSettings.h"
|
|
||||||
#include "WidgetAttributeText.h"
|
#include "WidgetAttributeText.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ All rights reserved.
|
|||||||
#ifndef _UTILITIES_H
|
#ifndef _UTILITIES_H
|
||||||
#define _UTILITIES_H
|
#define _UTILITIES_H
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
@@ -52,7 +55,6 @@ All rights reserved.
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BVolume;
|
class BVolume;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ All rights reserved.
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
#include <TranslationKit.h>
|
#include <TranslationKit.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <NetEndpoint.h>
|
#include <NetEndpoint.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// #define DEBUG 1
|
// #define DEBUG 1
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "pr_server.h"
|
#include "pr_server.h"
|
||||||
#include "SpoolFolder.h"
|
#include "SpoolFolder.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include <WindowInfo.h>
|
#include <WindowInfo.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <ShapePrivate.h>
|
#include <ShapePrivate.h>
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <DirectWindow.h>
|
#include <DirectWindow.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "PathList.h"
|
#include "PathList.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
BObjectList<MediaFilePlayer> list;
|
BObjectList<MediaFilePlayer> list;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
// BeOS
|
// BeOS
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user