5c88803942
Error handling: Array now has sufficiently advanced error handling to remove most, if not all, disable_checks. Extention: With the metaprogramming techniques, new types can be added easily. Speed: With the new changes I've made to Judy, the Array module has far exceeded the speed of any traditional datatype
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef _BINTRIECLASS_H
|
|
#define _BINTRIECLASS_H
|
|
|
|
#include "JudyIncludes.h"
|
|
//#include <Judy1.h>
|
|
|
|
class BinTrie
|
|
{
|
|
private:
|
|
Pvoid_t Table;
|
|
|
|
void ThrowSearchError(char* msg);
|
|
|
|
public:
|
|
BinTrie() { Table = NULL; }
|
|
~BinTrie() { Judy1FreeArray(&Table, PJE0); }
|
|
|
|
Word_t Clear() { return Judy1FreeArray(&Table, PJE0); }
|
|
Word_t MemoryUsed() { return Judy1MemUsed(Table); }
|
|
|
|
cell Delete(cell Key) { return Judy1Unset(&Table, Key, PJE0 ); }
|
|
|
|
cell Set(cell Index, bool val)
|
|
{
|
|
if(val == false) return Delete(Index);
|
|
else return Judy1Set(&Table, Index,PJE0);
|
|
}
|
|
|
|
cell Get(cell Index)
|
|
{
|
|
cell PValue = Judy1Test(Table, Index, PJE0);
|
|
return PValue;
|
|
}
|
|
|
|
cell First(cell Start = 0);
|
|
cell Next(cell Start = 0);
|
|
cell Prev(cell Start = -1);
|
|
cell Last(cell Start = -1);
|
|
|
|
cell FirstEmpty(cell Start = 0);
|
|
cell NextEmpty(cell Start = 0);
|
|
cell PrevEmpty(cell Start = -1);
|
|
cell LastEmpty(cell Start = -1);
|
|
|
|
cell ByCount(cell n, cell Start);
|
|
cell Count(cell Start = 0, cell Stop = -1) { return Judy1Count(Table, Start, Stop, PJE0); }
|
|
|
|
bool IsFilled(cell Index) { return ( (Get(Index )) ? true : false); }
|
|
bool IsEmpty(cell Index) { return ( (Get(Index )) ? true : false); }
|
|
};
|
|
|
|
#endif |