Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.string_table

Mir String Table designed for fast deserialization routines.
Authors:
Ilya Yaroshenko
struct MirStringTable(U, C = char) if (__traits(isUnsigned, U) && (is(C == char) || is(C == wchar) || is(C == dchar)));

struct MirStringTable(size_t length, size_t maxKeyLength, bool caseInsensetive = false, C = char) if (is(C == char) || is(C == wchar) || is(C == dchar));
Fast string table used to get key's id. The keys should be first sorted by length and then lexicographically.
const(immutable(C)[])[] sortedKeys;
pure nothrow @trusted this()(const(immutable(C)[])[] sortedKeys);
The keys should be first sorted by length and then lexicographically.
The constructor uses GC. It can be used in @nogc code when if constructed in compile time.
const pure nothrow @nogc @trusted bool get()(scope const C[] key, ref uint index);
Returns:
key's index or -1 if no key has been found.
const pure nothrow @nogc @trusted uint opIndex()(scope const C[] key);
sizediff_t smallerStringFirstCmp(T)(T[] a, T[] b);
Compares strings by length and then lexicographically.
Examples:
assert(smallerStringFirstCmp("aa", "bb") < 0);
assert(smallerStringFirstCmp("aa", "aa") == 0);
assert(smallerStringFirstCmp("aaa", "aa") > 0);

static assert(smallerStringFirstCmp("aa", "bb") < 0);
static assert(smallerStringFirstCmp("aa", "aa") == 0);
static assert(smallerStringFirstCmp("aaa", "aa") > 0);
template smallerStringFirst(alias direction = "<") if (direction == "<" || direction == ">")
Compares strings by length and then lexicographically.
Examples:
assert(smallerStringFirst("aa", "bb") == true);
assert(smallerStringFirst("aa", "aa") == false);
assert(smallerStringFirst("aaa", "aa") == false);
bool smallerStringFirst(T)(T[] a, T[] b);