35 namespace libdivsufsort {
38 #define ALPHABET_SIZE (UINT8_MAX + 1) 41 #define BUCKET_A_SIZE (ALPHABET_SIZE) 42 #define BUCKET_B_SIZE (ALPHABET_SIZE * ALPHABET_SIZE) 44 #if defined(SS_INSERTIONSORT_THRESHOLD) 45 # if SS_INSERTIONSORT_THRESHOLD < 1 46 # undef SS_INSERTIONSORT_THRESHOLD 47 # define SS_INSERTIONSORT_THRESHOLD (1) 50 # define SS_INSERTIONSORT_THRESHOLD (8) 52 #if defined(SS_BLOCKSIZE) 55 # define SS_BLOCKSIZE (0) 56 # elif 32768 <= SS_BLOCKSIZE 58 # define SS_BLOCKSIZE (32767) 61 # define SS_BLOCKSIZE (1024) 65 const ssize_t SS_MISORT_STACKSIZE = divsufsort64 ? 96 : 64;
66 #elif SS_BLOCKSIZE <= 4096 67 # define SS_MISORT_STACKSIZE (16) 69 # define SS_MISORT_STACKSIZE (24) 72 const ssize_t SS_SMERGE_STACKSIZE = divsufsort64 ? 64 : 32;
75 #define TR_INSERTIONSORT_THRESHOLD (8) 76 const ssize_t TR_STACKSIZE = divsufsort64 ? 96 : 64;
80 # define SWAP(_a, _b) do { t = (_a); (_a) = (_b); (_b) = t; } while(0) 83 # define MIN(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) 86 # define MAX(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) 88 #define STACK_PUSH(_a, _b, _c, _d)\ 90 assert(ssize < STACK_SIZE);\ 91 stack[ssize].a = (_a), stack[ssize].b = (_b),\ 92 stack[ssize].c = (_c), stack[ssize++].d = (_d);\ 94 #define STACK_PUSH5(_a, _b, _c, _d, _e)\ 96 assert(ssize < STACK_SIZE);\ 97 stack[ssize].a = (_a), stack[ssize].b = (_b),\ 98 stack[ssize].c = (_c), stack[ssize].d = (_d), stack[ssize++].e = (_e);\ 100 #define STACK_POP(_a, _b, _c, _d)\ 103 if(ssize == 0) { return; }\ 104 (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\ 105 (_c) = stack[ssize].c, (_d) = stack[ssize].d;\ 107 #define STACK_POP5(_a, _b, _c, _d, _e)\ 110 if(ssize == 0) { return; }\ 111 (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\ 112 (_c) = stack[ssize].c, (_d) = stack[ssize].d, (_e) = stack[ssize].e;\ 115 #define BUCKET_A(_c0) bucket_A[(_c0)] 116 #if ALPHABET_SIZE == 256 117 #define BUCKET_B(_c0, _c1) (bucket_B[((_c1) << 8) | (_c0)]) 118 #define BUCKET_BSTAR(_c0, _c1) (bucket_B[((_c0) << 8) | (_c1)]) 120 #define BUCKET_B(_c0, _c1) (bucket_B[(_c1) * ALPHABET_SIZE + (_c0)]) 121 #define BUCKET_BSTAR(_c0, _c1) (bucket_B[(_c0) * ALPHABET_SIZE + (_c1)]) Contains the text compression and encoding framework.