The C# OrderedSequence<T> Class

OrderedSequence<T> represents a sequence field whose elements are maintained in order and can be accessed either by position or by key range. In C# applications it is typically used as the ordering dimension of a time series, for example a sequence of timestamps or trading days.

For an overview see page C# Classes

Class Definition

    public class OrderedSequence<T> : UnorderedSequence<T>
    {
        public Sequence Search(object low, SelectBoundary lowBoundary,
                               object high, SelectBoundary highBoundary);
    }

Member Descriptions

OrderedSequence<T> class
Represents an ordered sequence field. In addition to the positional sequence operations inherited from UnorderedSequence<T>, it provides range search by element value.
Schema Declaration
Declare an ordered sequence field with the [Sequence(Order=SequenceOrder.Ascending)] or descending variant. In practice the ordered sequence usually acts as the key sequence for associated value sequences in the same object.
Inherited Operations
OrderedSequence<T> inherits the update and positional operations of UnorderedSequence<T>, including append, insert, delete, count, projection, subsequence extraction, and conversion to a Sequence iterator.
Search(object low, SelectBoundary lowBoundary, object high, SelectBoundary highBoundary)
Performs a range search over the ordered elements and returns a Sequence iterator representing the matching positions. Use this iterator directly or project related sequences through it.
low / high
Specify the lower and upper bound values for the search range. The values should match the declared element type T. If a boundary is SelectBoundary.Open, the corresponding bound value is ignored.
lowBoundary / highBoundary
Specify whether each boundary is open, inclusive, or exclusive. This allows closed, open, and half-open range searches to be expressed directly from C# code. See SelectBoundary for the enumeration values.
Return Value
Returns a Sequence iterator over the matching ordered-sequence positions. Typical follow-up operations are FirstPosition, LastPosition, projection of another sequence, or direct analytical processing of the matching slice.
Typical Usage
In the common time-series pattern, an ordered sequence such as Day is searched first, then related unordered sequences such as Price are projected using the returned Sequence. This is the standard way to select an interval and operate on the aligned values.
Resource Management
OrderedSequence<T> itself is a field wrapper and does not implement IDisposable. The Sequence returned by Search() does hold native resources and should be closed or disposed when no longer needed.
Type Parameter T
The generic parameter T indicates the logical element type stored in the ordered sequence, for example uint, DateTime, or another supported sequence element type.