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= T; - pure nothrow @nogc @safe void
proxySwap(ref typeof(this)rhs); - this(typeof(null));
- const pure nothrow @nogc scope @safe bool
opEquals(typeof(null));
const pure nothrow @nogc scope @safe boolopEquals(Y)(auto ref scope const ThisTemplate!Yrhs); - const pure nothrow @nogc scope @trusted int
opCmp(Y)(auto ref scope const ThisTemplate!Yrhs); - const pure nothrow @nogc scope @trusted size_t
toHash(); - const pure nothrow @nogc @property scope @trusted size_t
length(); - inout scope @system inout(T)*
ptr(); - inout ref scope @trusted auto
opIndex(size_ti); - inout scope @trusted inout(T)[]
opIndex(); - const pure nothrow @nogc scope @trusted size_t
opDollar(size_t pos : 0)(); - @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)) return; - ref @trusted auto
opAssign(return typeof(this)rhs) return; - ref @trusted auto
opAssign(Q)(return ThisTemplate!Qrhs) 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)(V[]values...)
if (is(T == void) && hasIndirections!V);
RCArray!Vrcarray(T = void, V)(scope V[]values...)
if (is(T == void) && !hasIndirections!V);
RCArray!Vrcarray(T = void, V)(V[]values, booldeallocate)
if (is(T == void) && hasIndirections!V);
RCArray!Vrcarray(T = void, V)(scope V[]values, booldeallocate)
if (is(T == void) && !hasIndirections!V);
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 scope @trusted inout(T)*
lightScope()() return; - nothrow ref scope auto
opAssign(typeof(null)) return; - ref scope @trusted auto
opAssign(return typeof(this)rhs) return; - nothrow ref scope auto
opAssign(Q)(return mir_rci!Qrhs) return
if (isImplicitlyConvertible!(Q*, T*)); - const nothrow @property scope mir_rci!(const(T))
lightConst()() return; - immutable nothrow @property scope mir_rci!(immutable(T))
lightImmutable()() return; - inout ref scope inout(T)
opUnary(string op : "*")() return; - inout ref scope @trusted inout(T)
opIndex(ptrdiff_tindex) return; - const scope @safe Slice!(IotaIterator!size_t)
opSlice(size_t dimension)(size_ti, size_tj)
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
- scope void
opUnary(string op)()
if (op == "--" || op == "++"); - scope void
opOpAssign(string op)(ptrdiff_tindex)
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 scope ptrdiff_t
opBinary(string op : "-")(ref scope const typeof(this)right); - const scope bool
opEquals()(ref scope const typeof(this)right); - const scope int
opCmp()(ref scope const typeof(this)right);
Copyright © 2016-2022 by Ilya Yaroshenko | Page generated by
Ddoc on Tue Jan 11 06:37:12 2022