Browse Source

Remove more unused pnUtils code.

Darryl Pogue 13 years ago
parent
commit
b8e4f00ad6
  1. 34
      Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h
  2. 48
      Sources/Plasma/NucleusLib/pnUtils/pnUtPriQ.h
  3. 46
      Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h

34
Sources/Plasma/NucleusLib/pnUtils/pnUtHash.h

@ -62,24 +62,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Define a field inside an object that is used to link it into a hash table // Define a field inside an object that is used to link it into a hash table
#define HASHLINK(object) THashLink< object > #define HASHLINK(object) THashLink< object >
// Define a POINTER to a hash table, not a hash table
#define HASHTABLE(object,key) THashTable< object, key >
// Define a hash table: // Define a hash table:
// - starts with kSlotMinCount rows // - starts with kSlotMinCount rows
// - can grow to kDefaultSlotMaxCount rows // - can grow to kDefaultSlotMaxCount rows
// (hash table grows when a row contains more than kGrowOnListSize entries // (hash table grows when a row contains more than kGrowOnListSize entries
#define HASHTABLEDECL(object,key,link) THashTableDecl< object, key, offsetof(object,link), 0 > #define HASHTABLEDECL(object,key,link) THashTableDecl< object, key, offsetof(object,link), 0 >
// Define a hash table in situations when a forward reference prevents use of HASHTABLEDECL
// - Size characteristics are identical to HASHTABLEDECL
#define HASHTABLEDYN(object,key) THashTableDyn< object, key >
// Define a hash table with:
// - starts with <size>
// - row table never grows
#define HASHTABLEDECLSIZE(object,key,link,size) THashTableDecl<object, key, offsetof(object,link), size >
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define forceinline __forceinline #define forceinline __forceinline
@ -595,28 +583,6 @@ THashTableDecl<T,K,linkOffset,maxSize>::THashTableDecl () {
} }
/****************************************************************************
*
* THashTableDyn
*
***/
template<class T, class K>
class THashTableDyn : public THashTable<T,K> {
public:
void Initialize (int linkOffset, unsigned maxSize = 0);
};
//===========================================================================
template<class T, class K>
void THashTableDyn<T,K>::Initialize (int linkOffset, unsigned maxSize) {
this->SetLinkOffset(linkOffset, maxSize);
this->SetSlotMaxCount(maxSize);
}
/**************************************************************************** /****************************************************************************
* *
* THashKeyVal * THashKeyVal

48
Sources/Plasma/NucleusLib/pnUtils/pnUtPriQ.h

@ -57,11 +57,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
***/ ***/
#define PRIORITY_TIME(class) TPriorityTime< class > #define PRIORITY_TIME(class) TPriorityTime< class >
#define PRIORITY_NUMERIC(class,type) TPriorityNumeric< class,type >
#define PRIQ(class,priority) TPriorityQueue< class,priority > #define PRIQ(class,priority) TPriorityQueue< class,priority >
#define PRIQDECL(class,priority,field) TPriorityQueueDecl< class,priority,offsetof(class,field) > #define PRIQDECL(class,priority,field) TPriorityQueueDecl< class,priority,offsetof(class,field) >
#define PRIQDYN(class,priority) TPriorityQueueDyn< class,priority >
/**************************************************************************** /****************************************************************************
@ -351,19 +349,6 @@ public:
}; };
/****************************************************************************
*
* TPriorityQueueDyn
*
***/
template<class C, class P>
class TPriorityQueueDyn : public TPriorityQueue<C,P> {
public:
void Initialize (int linkOffset) { this->SetLinkOffset(linkOffset); }
};
/**************************************************************************** /****************************************************************************
* *
* class TBasePriority * class TBasePriority
@ -419,39 +404,6 @@ void TBasePriority<C,P>::Relink () {
queue->Enqueue(object); queue->Enqueue(object);
} }
/****************************************************************************
*
* class TPriorityNumeric
*
***/
template<class C,class T>
class TPriorityNumeric : public TBasePriority< C, TPriorityNumeric<C,T> > {
public:
TPriorityNumeric () : m_value(0) { }
TPriorityNumeric (T value) : m_value(value) { }
void Set (T value) {
if (value == m_value)
return;
m_value = value;
this->Relink();
}
T Get () const {
return m_value;
}
bool IsPriorityHigher (const TPriorityNumeric<C,T> & source) {
return m_value > source.m_value;
}
bool IsPriorityHigher (T value) const {
return m_value > value;
}
private:
T m_value;
};
/**************************************************************************** /****************************************************************************
* *
* class TPriorityTime * class TPriorityTime

46
Sources/Plasma/NucleusLib/pnUtils/pnUtSort.h

@ -191,50 +191,4 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
} \ } \
} \ } \
} }
/****************************************************************************
*
* BSEARCH
*
* This macro binary searches a sorted array to find an existing entry or
* the position where a new entry should be placed. It returns the index of
* the first entry for which the expression is false (zero or negative), or
* count if the expression is true (positive) for all entries.
*
* Typically the expression will return:
* > 0 if (sortKey > elem)
* <= 0 if (sortKey <= elem)
*
* The final parameter to the macro is the address of a variable which is
* filled with the resulting index.
*
***/
//===========================================================================
#define BSEARCH(T, ptr, count, expr, addrOfIndex) { \
\
const T * low = (ptr); \
const T * high = (ptr) + (count); /* first entry for which */ \
/* expr is false */ \
\
if (low != high) \
for (;;) { \
const T & elem = *(low + (high - low) / 2); \
int result = (expr); \
if (result > 0) { \
if (&elem == low) \
break; \
low = &elem; \
} \
else { \
high = &elem; \
if (&elem == low) \
break; \
} \
} \
\
*(addrOfIndex) = high - (ptr); \
\
}
#endif #endif

Loading…
Cancel
Save