makeUnionSeries

Merges multiple (time) series into one.

@optmath
makeUnionSeries
(
IndexIterator
Iterator
size_t N
SliceKind kind
size_t C
Allocator
)
(
auto ref Allocator allocator
,
Series!(IndexIterator, Iterator, N, kind)[C] seriesTuple...
)
if (
C > 1
)

Parameters

allocator Allocator

memory allocator

seriesTuple Series!(IndexIterator, Iterator, N, kind)[C]

variadic static array of composed of series.

Return Value

Type: auto

sorted manually allocated series. See_also unionSeries

Examples

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

//////////////////////////////////////
// Constructs two time-series.
//////////////////////////////////////
auto index0 = [1,3,4];

auto data0 = [1.0, 3, 4];
auto series0 = index0.series(data0);

auto index1 = [1,2,5];

auto data1 = [10.0, 20, 50];
auto series1 = index1.series(data1);

//////////////////////////////////////
// Merges multiple series into one.
//////////////////////////////////////

InSituRegion!(1024) allocator;

auto m0 = allocator.makeUnionSeries(series0, series1);
auto m1 = allocator.makeUnionSeries(series1, series0); // order is matter

assert(m0.index == m1.index);
assert(m0.data == [ 1, 20,  3,  4, 50]);
assert(m1.data == [10, 20,  3,  4, 50]);

/// series should have the same sizes as after allocation
allocator.dispose(m0.index.field);
allocator.dispose(m0.data.field);
allocator.dispose(m1.index.field);
allocator.dispose(m1.data.field);

Meta