createTable

Undocumented in source.
template createTable(C)
package
createTable
(
immutable(C)[][] keys
bool caseInsensetive = false
)
()
if (
is(C == char) ||
is(C == wchar)
||
is(C == dchar)
)

Members

Functions

createTable
auto createTable()
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

static immutable sortedKeys = ["", "a", "b", "aab", "abb", "aaaaa"];
static immutable table = MirStringTable!ubyte(sortedKeys); // CTFE
static assert (table[""] == 0);
static assert (table["a"] == 1);
static assert (table["b"] == 2);
static assert (table["abb"] == 4);
assert (table["aaaaa"] == 5);
import mir.utility: simpleSort;
auto keys = ["aaaaa", "abb", "", "b", "a", "aab"];
// sorts keys by length and then lexicographically.
keys.simpleSort!smallerStringFirst;
assert(keys == ["", "a", "b", "aab", "abb", "aaaaa"]);

Meta