The OpenD Programming Language

makeSeries

Constructs a manually allocated series from an associative array. Performs exactly two allocations.

  1. Series!(K*, V*) makeSeries(Allocator allocator, V[K] aa)
    Series!(K*, V*)
    makeSeries
    (
    Allocator
    K
    V
    )
    (
    auto ref Allocator allocator
    ,
    V[K] aa
    )
    if (
    is(typeof(K.init < K.init)) &&
    is(typeof(Unqual!K.init < Unqual!K.init))
    )
  2. Series!(K*, V*) makeSeries(Allocator allocator, V[K]* aa)

Parameters

aa V[K]

= associative array or a pointer to associative array

Return Value

Type: Series!(K*, V*)

sorted manually allocated series.

Examples

import std.experimental.allocator;
import std.experimental.allocator.building_blocks.region;

InSituRegion!(1024) allocator;
auto aa = [1: 1.5, 3: 3.3, 2: 2.9];

auto s = (double[int] aa) @nogc @trusted pure nothrow {
    return allocator.makeSeries(aa);
}(aa);

auto indexArray = s.index.field;
auto dataArray = s.data.field;

assert(s.index == [1, 2, 3]);
assert(s.data == [1.5, 2.9, 3.3]);
assert(s.data[s.findIndex(2)] == 2.9);

allocator.dispose(indexArray);
allocator.dispose(dataArray);

Meta