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.rc.array
Thread-safe reference-counted arrays and iterators
.- struct
mir_rcarray(T);
aliasRCArray= mir_rcarray(T); - Thread safe reference counting array.The implementation never adds roots into the GC.Examples:
auto a = RCArray!double(10); foreach(i, ref e; a) e = i; auto b = a; assert(b[$ - 1] == 9); foreach(i, ref e; b) assert(e == i); b[4] = 100; assert(a[4] == 100); import mir.ndslice.slice; auto s = a.asSlice; // as RC random access range (ndslice) static assert(is(typeof(s) == Slice!(RCI!double))); static assert(is(typeof(s) == mir_slice!(mir_rci!double))); auto r = a[]; // scope array static assert(is(typeof(r) == double[])); auto fs = r.sliced; // scope fast random access range (ndslice) static assert(is(typeof(fs) == Slice!(double*)));
- T*
_payload; - alias
serdeKeysProxy= Unqual!T; - pure nothrow @nogc @safe void
proxySwap(ref typeof(this)rhs); - this(typeof(null));
- const pure nothrow @nogc @safe bool
opEquals(typeof(null)) scope;
const pure nothrow @nogc @safe boolopEquals(Y)(auto ref scope const ThisTemplate!Yrhs) scope; - const pure nothrow @nogc @trusted int
opCmp(Y)(auto ref scope const ThisTemplate!Yrhs) scope; - const pure nothrow @nogc @trusted size_t
toHash() scope; - const pure nothrow @nogc @property @trusted size_t
length() scope; - inout @system inout(T)*
ptr() scope; - inout ref @trusted auto
opIndex(size_ti) scope; - inout @trusted inout(T)[]
opIndex() scope; - const pure nothrow @nogc @trusted size_t
opDollar(size_t pos : 0)() scope; - @property auto
asSlice()(); - const @property auto
asSlice()(); - immutable @property auto
asSlice()(); - @property auto
moveToSlice()(); - @nogc @trusted this(size_t
length, boolinitialize= true, booldeallocate= true); - Parameters:
size_t lengtharray length bool initializeFlag, don't initialize memory with default value if false. bool deallocateFlag, never deallocates memory if false. - ref @trusted auto
opAssign(typeof(null)) scope return; - ref @trusted auto
opAssign(return scope typeof(this)rhs) scope return; - ref @trusted auto
opAssign(Q)(return scope ThisTemplate!Qrhs) scope return
if (isImplicitlyConvertible!(Q*, T*));
- auto
rcarray(T = void, Range)(ref Rangerange)
if (is(T == void) && !is(Range == LightScopeOf!Range));
autorcarray(T = void, Range)(Rangerange)
if (is(T == void) && isIterable!Range && is(Range == LightScopeOf!Range) && !isArray!Range);
RCArray!Vrcarray(T = void, V)(scope V[]values...)
if (is(T == void));
RCArray!Vrcarray(T = void, V)(scope V[]values, booldeallocate)
if (is(T == void));
templatercarray(T) if (!is(T == E[], E) && !is(T == void)) - Examples:
RCArray!double a = rcarray!double(1.0, 2, 5, 3); assert(a[0] == 1); assert(a[$ - 1] == 3); auto s = rcarray!char("hello!"); assert(s[0] == 'h'); assert(s[$ - 1] == '!'); alias rcstring = rcarray!(immutable char); auto r = rcstring("string"); assert(r[0] == 's'); assert(r[$ - 1] == 'g');
Examples:With Input Rangesimport mir.algorithm.iteration: filter; static immutable numbers = [3, 2, 5, 2, 3, 7, 3]; static immutable filtered = [5.0, 7]; auto result = numbers.filter!"a > 3".rcarray!(immutable double); static assert(is(typeof(result) == RCArray!(immutable double))); assert (result[] == filtered);
- RCArray!T
mininitRcarray(T)(size_tlength, booldeallocate= true); - Parameters:
size_t lengtharray length bool deallocateFlag, never deallocates memory if false. Returns:minimally initialized rcarray.Examples:auto a = mininitRcarray!double(5); assert(a.length == 5); assert(a._counter == 1); a[][] = 0; // a.opIndex()[] = 0;
- struct
mir_rci(T);
aliasRCI= mir_rci(T); - Thread safe reference counting iterator.Examples:
import mir.ndslice.traits: isIterator; import mir.ndslice.slice; import mir.rc.array; auto slice = mir_rcarray!double(10).asSlice; static assert(isIterator!(RCI!double)); static assert(is(typeof(slice) == Slice!(RCI!double))); auto matrix = slice.sliced(2, 5); static assert(is(typeof(matrix) == Slice!(RCI!double, 2))); slice[7] = 44; assert(matrix[1, 2] == 44);
Examples:import mir.ndslice.slice; import mir.rc.array; alias rcvec = Slice!(RCI!double); RCI!double a, b; a = b; RCI!(const double) ca, cb; ca = cb; ca = cast(const) cb; void foo(scope ref rcvec x, scope ref rcvec y) { x[] = y[]; x[1] = y[1]; x[1 .. $] += y[1 .. $]; x = x.save; }
- T*
_iterator; - RCArray!T
_array; - this(RCArray!T
array); - this(T*
_iterator, RCArray!Tarray); - inout @property @trusted inout(T)*
lightScope()() return scope; - nothrow ref auto
opAssign(typeof(null)) scope return; - ref @trusted auto
opAssign(return typeof(this)rhs) scope return; - nothrow ref auto
opAssign(Q)(return mir_rci!Qrhs) scope return
if (isImplicitlyConvertible!(Q*, T*)); - const nothrow @property mir_rci!(const(T))
lightConst()() return scope; - immutable nothrow @property mir_rci!(immutable(T))
lightImmutable()() return scope; - inout ref inout(T)
opUnary(string op : "*")() return scope; - inout ref @trusted inout(T)
opIndex(ptrdiff_tindex) return scope; - const @safe Slice!(IotaIterator!size_t)
opSlice(size_t dimension)(size_ti, size_tj) scope
if (dimension == 0); - Returns:slice type of Slice!(IotaIterator!size_t)
- auto
opIndex(Slice!(IotaIterator!size_t)slice);
const autoopIndex(Slice!(IotaIterator!size_t)slice); - Returns:ndslice on top of the refcounted iterator
- void
opUnary(string op)() scope
if (op == "--" || op == "++"); - void
opOpAssign(string op)(ptrdiff_tindex) scope
if (op == "-" || op == "+"); - mir_rci!T
opBinary(string op)(ptrdiff_tindex)
if (op == "+" || op == "-"); - const mir_rci!(const(T))
opBinary(string op)(ptrdiff_tindex)
if (op == "+" || op == "-"); - immutable mir_rci!(immutable(T))
opBinary(string op)(ptrdiff_tindex)
if (op == "+" || op == "-"); - const ptrdiff_t
opBinary(string op : "-")(ref scope const typeof(this)right) scope; - const bool
opEquals()(ref scope const typeof(this)right) scope; - const int
opCmp()(ref scope const typeof(this)right) scope;
Copyright © 2016-2026 by Ilya Yaroshenko | Page generated by
Ddoc on Wed Apr 8 13:47:04 2026