1 module judy.libjudy; 2 3 // Interface to C implementation of libjudy 4 extern(C) 5 { 6 enum Errno 7 { 8 JU_ERRNO_NONE = 0, 9 JU_ERRNO_FULL = 1, 10 JU_ERRNO_NFMAX = JU_ERRNO_FULL, 11 JU_ERRNO_NOMEM = 2, 12 JU_ERRNO_NULLPPARRAY = 3, 13 JU_ERRNO_NONNULLPARRAY = 10, 14 JU_ERRNO_NULLPINDEX = 4, 15 JU_ERRNO_NULLPVALUE = 11, 16 JU_ERRNO_NOTJUDY1 = 5, 17 JU_ERRNO_NOTJUDYL = 6, 18 JU_ERRNO_NOTJUDYSL = 7, 19 JU_ERRNO_UNSORTED = 12, 20 JU_ERRNO_OVERRUN = 8, 21 JU_ERRNO_CORRUPT = 9, 22 } 23 24 struct Error 25 { 26 Errno errno; 27 int errID; 28 size_t[4] reserved; 29 } 30 31 Error* NO_ERROR = null; 32 } 33 34 //JudyL 35 extern(C) 36 { 37 // Retrieve pointer to address of element at index 38 void** JudyLGet(const void* array, size_t index, Error* err) nothrow @nogc; 39 40 // Insert and retrieve pointer to address of element at index 41 void** JudyLIns(void** array, size_t index, Error* err) nothrow @nogc; 42 int JudyLInsArray(void** array, size_t count, const size_t* index, const size_t* value) nothrow @nogc; 43 44 // Remove element at index, return 1 if successful, 0 if Index not present, 45 // error otherwise 46 int JudyLDel(void** array, size_t index, Error* err) nothrow @nogc; 47 48 // Count number of elements between index1 and index2 inclusively 49 size_t JudyLCount(const void* array, size_t index1, size_t index2, Error* err) nothrow @nogc; 50 // Find the index of the nth element of the array 51 void** JudyLByCount(const void* array, size_t nth, size_t* index, Error* err) nothrow @nogc; 52 53 size_t JudyLFreeArray(void** array, Error* err) nothrow @nogc; 54 size_t JudyLMemUsed(const void* array) nothrow @nogc; 55 size_t JudyLMemActive(const void* array) nothrow @nogc; 56 57 void** JudyLFirst(const void* array, size_t* index, Error* err) nothrow @nogc; 58 void** JudyLNext(const void* array, size_t* index, Error* err) nothrow @nogc; 59 void** JudyLLast(const void* array, size_t* index, Error* err) nothrow @nogc; 60 void** JudyLPrev(const void* array, size_t* index, Error* err) nothrow @nogc; 61 62 int JudyLFirstEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 63 int JudyLNextEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 64 int JudyLLastEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 65 int JudyLPrevEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 66 } 67 68 //Judy1 69 extern(C) 70 { 71 int Judy1Test(const void* array, size_t index, Error* err) nothrow @nogc; 72 int Judy1Set(void** array, size_t index, Error* err) nothrow @nogc; 73 int Judy1SetArray(void** array, size_t cound, const size_t* index, Error* err) nothrow @nogc; 74 75 int Judy1Unset(void** array, size_t index, Error* err) nothrow @nogc; 76 size_t Judy1Count(const void* array, size_t index1, size_t index2, Error* err) nothrow @nogc; 77 int Judy1ByCount(const void* array, size_t count, size_t* index, Error* err) nothrow @nogc; 78 79 size_t Judy1FreeArray(void** array, Error* err) nothrow @nogc; 80 size_t Judy1MemUsed(const void* array) nothrow @nogc; 81 size_t Judy1MemActive(const void* array) nothrow @nogc; 82 83 int Judy1First(const void* array, size_t* index, Error* err) nothrow @nogc; 84 int Judy1Next(const void* array, size_t* index, Error* err) nothrow @nogc; 85 int Judy1Last(const void* array, size_t* index, Error* err) nothrow @nogc; 86 int Judy1Prev(const void* array, size_t* index, Error* err) nothrow @nogc; 87 int Judy1FirstEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 88 int Judy1NextEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 89 int Judy1LastEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 90 int Judy1PrevEmpty(const void* array, size_t* index, Error* err) nothrow @nogc; 91 }