Miscellaneous Sequence Helpers in C#

These helper APIs support sequence construction, duplication, sorting, and histogram-style processing.

In the C# API, analytics operate on Sequence values obtained from OrderedSequence<T> searches, direct ordered-sequence iteration, UnorderedSequence<T>.All, or positional projections such as quote.Close[dayRange].

For an overview see page The C# Sequence Class

Operations

source.Histogram(object low, object high, int nIntervals)
Builds a histogram sequence across the requested value range.
source.Sort(Array values, SequenceOrder order)
Sorts extracted values and returns the permutation needed to reorder related arrays.
source.Tee()
Duplicates a sequence into two independently readable Sequence objects.
Sequence.Parse(Connection con, string value, Type elemType)
Parses a textual sequence literal.
Sequence.Constant(Connection con, value)
Creates a constant sequence with the requested runtime type.
Sequence.Concat(left, right)
Appends one sequence to another.
Sequence.Cat(left, right)
Concatenates corresponding elements from two sequences.

Example

The seqapi sample extracts arrays, sorts them through the sequence API, and then reuses the returned permutation to keep related arrays aligned.

    int count = (int)quote.Volume.Count;
    int[] volumes = new int[count];
    float[] prices = new float[count];

    quote.Volume.All.Get(volumes);
    quote.Close.All.Get(prices);

    ulong[] permutation = quote.Volume.All.Sort(volumes, SequenceOrder.Descending);
    for (int i = 0; i < count; i++)
    {
        int j = (int)permutation[i];
        printf("%s: volume=%u, price=%.3f\n",
               __arglist(quote.Symbol, volumes[j], (double)prices[j]));
    }