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.small_array
Small Array
The module contains self-contained generic small array implementaton.
SmallArray supports ASDF - Json Serialisation Library.
Authors:
Ilia Ki
- struct
SmallArray(T, uint maxLength) if (maxLength); - Examples:
SmallArray!(char, 16) s16; assert(s16.empty); auto s8 = SmallArray!(char, 8)("Hellow!!"); assert(!s8.empty); assert(s8 == "Hellow!!"); s16 = s8; assert(s16 == "Hellow!!"); s16[7] = '@'; s8 = null; assert(s8.empty); assert(s8 == null); s8 = s16; assert(s8 == "Hellow!@"); auto s8_2 = s8; assert(s8_2 == "Hellow!@"); assert(s8_2 == s8); assert(s8 < "Hey"); assert(s8 > "Hellow!"); assert(s8.opCmp("Hey") < 0); assert(s8.opCmp(s8) == 0);
Examples:Concatenationauto a = SmallArray!(char, 16)("asdf"); a ~= " "; auto b = a ~ "qwerty"; static assert(is(typeof(b) == SmallArray!(char, 16))); assert(b == "asdf qwerty"); b.put('!'); b.put("!"); assert(b == "asdf qwerty!!");
- alias
serdeKeysProxy= T; - this(typeof(null));
this(scope V[]array);
nothrow this(const SmallArrayarray);
this(uint n)(const SmallArray!(T, n)array);
this(uint n)(const ref SmallArray!(T, n)array);
this(Range)(auto ref Rangearray)
if (isIterable!Range); - Constructor
- ref typeof(this)
opAssign(typeof(null)) scope return;
ref @trusted typeof(this)opAssign(V[]array) scope return;
nothrow ref typeof(this)opAssign(const ref SmallArrayrhs) scope return;
nothrow ref typeof(this)opAssign(const SmallArrayrhs) scope return;
ref typeof(this)opAssign(uint n)(const ref SmallArray!(T, n)rhs) scope return
if (n != maxLength);
ref typeof(this)opAssign(uint n)(const SmallArray!(T, n)rhs) scope return
if (n != maxLength); - = operator
- @trusted void
trustedAssign(V[]array); - ref typeof(this)
append(Telem); - void
trustedAppend(Telem); - ref typeof(this)
append(V[]array);
aliasput= append;
templateopOpAssign(string op : "~") - const SmallArray
concat(V[]array) scope;
templateopBinary(string op : "~") - inout @trusted inout(T)[]
opIndex() scope return; - Returns an scope common array.The property is used as common array representation self alias. The alias helps with [], [i], [i .. j], ==, and != operations and implicit conversion to strings.
- inout ref inout(T)
opIndex(size_tindex) scope return; - @property bool
empty(); - @property size_t
length(); - size_t
toHash(); - Hash implementation
- bool
opEquals(ref scope const SmallArrayrhs);
boolopEquals(SmallArrayrhs);
boolopEquals()(scope const V[]array);
boolopEquals(uint rhsMaxLength)(auto ref scope SmallArray!(T, rhsMaxLength)array);
autoopCmp()(scope const V[]array);
autoopCmp(uint rhsMaxLength)(auto ref scope const SmallArray!(T, rhsMaxLength)array); - Comparisons operator overloads
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:04 2026