mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
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
87 lines
2.1 KiB
C++
87 lines
2.1 KiB
C++
#include "CArray.h"
|
|
|
|
void Array::ThrowSearchError(char* type)
|
|
{
|
|
char value[50];
|
|
sprintf(value,"Function attempted to search %s: Judy returned NULL value", type);
|
|
|
|
throw JudyEx(value,false);
|
|
}
|
|
|
|
void Array::ThrowIndexError( cell index, bool disable_check )
|
|
{
|
|
if(disable_check == true) return;
|
|
|
|
char error[50];
|
|
sprintf(error,"Index %i is not set.",index);
|
|
|
|
throw JudyEx(error,true);
|
|
}
|
|
|
|
cell Array::First( cell Start)
|
|
{
|
|
PPvoid_t success = JudyLFirst(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:First");
|
|
|
|
return Start;
|
|
}
|
|
|
|
cell Array::FirstEmpty( cell Start)
|
|
{
|
|
cell success = JudyLFirstEmpty(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:FirstEmpty");
|
|
return Start;
|
|
}
|
|
|
|
cell Array::Next( cell Start)
|
|
{
|
|
PPvoid_t success = JudyLNext(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:Next");
|
|
|
|
return Start;
|
|
}
|
|
|
|
cell Array::NextEmpty( cell Start)
|
|
{
|
|
cell success = JudyLNextEmpty(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:NextEmpty");
|
|
return Start;
|
|
}
|
|
|
|
cell Array::Prev( cell Start)
|
|
{
|
|
PPvoid_t success = JudyLPrev(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:Prev");
|
|
|
|
return Start;
|
|
}
|
|
|
|
cell Array::PrevEmpty( cell Start)
|
|
{
|
|
cell success = JudyLPrevEmpty(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:PrevEmpty");
|
|
return Start;
|
|
}
|
|
|
|
cell Array::Last( cell Start)
|
|
{
|
|
PPvoid_t success = JudyLLast(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:Last");
|
|
|
|
return Start;
|
|
}
|
|
|
|
cell Array::LastEmpty( cell Start)
|
|
{
|
|
cell success = JudyLLastEmpty(Table, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:LastEmpty");
|
|
return Start;
|
|
}
|
|
|
|
cell Array::ByCount(cell n, cell Start)
|
|
{
|
|
PPvoid_t success = JudyLByCount(Table, n, reinterpret_cast<Word_t *>(&Start), PJE0);
|
|
if (success == NULL) ThrowSearchError("Type:Nth");
|
|
|
|
return Start;
|
|
} |