The OpenD Programming Language

assocArray

Returns a newly allocated associative array from a range of key/value tuples.

assocArray
(
IndexIterator
Iterator
size_t N
SliceKind kind
)
(
Series!(IndexIterator, Iterator, N, kind) series
)

Parameters

series Series!(IndexIterator, Iterator, N, kind)

index / time Series, may not be sorted

Return Value

Type: auto

A newly allocated associative array out of elements of the input series. Returns a null associative array reference when given an empty series.

Duplicates: Associative arrays have unique keys. If r contains duplicate keys, then the result will contain the value of the last pair for that key in r.

Examples

import mir.ndslice; //iota and etc
import mir.series;

auto s = ["c", "a", "b"].series(3.iota!int);
assert(s.assocArray == [
    "c": 0,
    "a": 1,
    "b": 2,
]);

Meta