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.
License:
Authors:
Ilya Yaroshenko
- struct
MirStringTable
(U, C = char) if (__traits(isUnsigned, U) && (is(C == char) || is(C == wchar) || is(C == dchar)));
structMirStringTable
(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.Parameters:
U an unsigned type that can hold an index of sorted keys. U.max must be less then length of the table. C character type - const(immutable(C)[])[]
sortedKeys
; - Keys sorted by length and then lexicographically.
- 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 uintindex
); - Parameters:
C[] key
string to find index for uint index
(ref) index to fill with key's position. Returns:true if keys index 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
);
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Mon Feb 14 19:04:07 2022