lu.array

Simple array utilities.

Members

Classes

ArrayException
class ArrayException

Exception, to be thrown when there was an array-related error.

Functions

pruneAA
void pruneAA(AA aa)

Iterates an associative array and deletes invalid entries, either if the value is in a default .init state or as per the optionally passed predicate.

truthTable
auto truthTable(Numbers numbers)

Generates a truth table from a list of runtime numbers.

truthTable
auto truthTable(Enums values)

Generates a truth table from a list of runtime enum values.

truthTable
auto truthTable()

Generates a static truth table from a list of compile-time numbers.

truthTable
auto truthTable()

Generates a static truth table from a list of compile-time enum values.

uniqueKey
auto uniqueKey(AA aa, K min, K max, V value)

Returns a unique key for the passed associative array. Reserves the key by assigning it a value.

zero
void zero(Sink sink, bool clear, T zeroValue)

Zeroes out the contents of an Appender.

Examples

string[int] aa;

immutable key = aa.uniqueKey;

assert(key > 0);
assert(key in aa);
assert(aa[key] == string.init);

Appender!(int]) sink;
sink.put(1);
sink.put(2);
sink.put(3);

sink.zero(clear: false);
assert(sink[] == [ 0, 0, 0 ]);

sink.zero(clear: false, 42);
assert(sink[] == [ 42, 42, 42 ]);

sink.zero();  //(clear: true);
assert(!sink[].length);

immutable table = truthTable(1, 3, 5);
assert((table.length == 6));
assert(table == [ false, true, false, true, false, true ]);

enum E { a, b, c, d }

const enumTable = truthTable(E.b, E.c);
assert((enumTable.length == 3));
assert(enumTable == [ false, true, true, false ]);

static staticTable = truthTable!(Yes.fullEnumRange, E.a, E.b);
assert(is(typeof(staticTable) == bool[4]));
assert(staticTable == [ true, true, false, false ]);

immutable staticNumTable = truthTable!(2, 4, 6);
assert(is(typeof(staticNumTable) == bool[7]));
assert(staticNumTable == [ false, false, true, false, true, false, true ]);

Meta