Search Results for

    Show / Hide Table of Contents

    Class CursorArray<CursorType>

    A multidimensional array of objects which share a single storage block.

    Inheritance
    Object
    CursorArray<CursorType>
    Implements
    ICursor
    ICloneable
    ICursorArray<CursorType>
    IEnumerable<CursorType>
    ICursorArray
    IEnumerable
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Microsoft.ML.Probabilistic.Collections
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    public class CursorArray<CursorType> : ICursor, ICloneable, ICursorArray<CursorType>, IEnumerable<CursorType>, ICursorArray, IEnumerable where CursorType : ICursor
    Type Parameters
    Name Description
    CursorType
    Remarks

    A CursorArray is meant to behave like an ordinary Array, while being more memory-efficient. Instead of storing multiple instances of the same object type, it uses a single instance as a cursor over a block of data. The cursor acts like a pointer which is targeted at the desired part of the array (via its Start property).

    The CursorArray object does not hold a pointer to the actual source data. It is agnostic about the actual type and layout of the data that the cursor is walking over, providing a large degree of flexibility in the implementation of the cursor.

    Constructors

    CursorArray(CursorType)

    Declaration
    public CursorArray(CursorType cursor)
    Parameters
    Type Name Description
    CursorType cursor

    CursorArray(CursorType, IList<Int32>, IList<Int32>)

    Declaration
    public CursorArray(CursorType cursor, IList<int> lengths, IList<int> stride)
    Parameters
    Type Name Description
    CursorType cursor
    IList<Int32> lengths
    IList<Int32> stride

    CursorArray(CursorType, Int32[])

    Declaration
    public CursorArray(CursorType cursor, params int[] lengths)
    Parameters
    Type Name Description
    CursorType cursor
    Int32[] lengths

    Fields

    count

    Declaration
    protected int[] count
    Field Value
    Type Description
    Int32[]

    cursor

    Declaration
    protected CursorType cursor
    Field Value
    Type Description
    CursorType

    dim

    Declaration
    protected int[] dim
    Field Value
    Type Description
    Int32[]

    start

    Declaration
    protected int start
    Field Value
    Type Description
    Int32

    stride

    Declaration
    protected int[] stride
    Field Value
    Type Description
    Int32[]

    Properties

    Count

    The total number of structures across all dimensions

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    Item[Int32]

    Retrieve an object by linear index.

    Declaration
    public CursorType this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index
    Property Value
    Type Description
    CursorType
    Remarks

    If the array is multidimensional, this will index the elements sequentially in row-major order, i.e. the rightmost dimension varies fastest.

    The result is a volatile cursor object, which becomes invalid on the next indexer call. This can be a source of bugs, e.g. f(a[i],a[j]) will not work. If you want to save a result across calls, you must make a ReferenceClone, as in: f(a[i].ReferenceClone(), a[j]).

    Item[Int32[]]

    Retrieve an object by multidimensional index.

    Declaration
    public CursorType this[params int[] index] { get; }
    Parameters
    Type Name Description
    Int32[] index
    Property Value
    Type Description
    CursorType
    Remarks

    The result is a volatile cursor object, which becomes invalid on the next indexer call. This can be a source of bugs, e.g. f(a[i],a[j]) will not work. If you want to save a result across calls, you must make a ReferenceClone, as in: f(a[i].ReferenceClone(), a[j]).

    Lengths

    The size of each dimension of the array.

    Declaration
    public IList<int> Lengths { get; protected set; }
    Property Value
    Type Description
    IList<Int32>

    Rank

    The number of dimensions of the array.

    Declaration
    public int Rank { get; }
    Property Value
    Type Description
    Int32

    Start

    Declaration
    public int Start { get; set; }
    Property Value
    Type Description
    Int32

    Stride

    Declaration
    public int[] Stride { get; }
    Property Value
    Type Description
    Int32[]

    Methods

    CheckCompatible(ICursorArray)

    Declaration
    public void CheckCompatible(ICursorArray that)
    Parameters
    Type Name Description
    ICursorArray that

    Clone()

    Declaration
    public virtual object Clone()
    Returns
    Type Description
    Object

    CreateSourceArray(Int32)

    Declaration
    public void CreateSourceArray(int nRecords)
    Parameters
    Type Name Description
    Int32 nRecords

    ForEach(ICursorArray, ICursorArray, Action)

    Invoke an element-wise action across three arrays.

    Declaration
    public void ForEach(ICursorArray a, ICursorArray b, Action action)
    Parameters
    Type Name Description
    ICursorArray a

    An array of the same size as this. Can be the same object as this.

    ICursorArray b

    An array of the same size as this. Can be the same object as this.

    Action action

    A delegate which accesses the array cursors.

    ForEach(ICursorArray, Action)

    Invoke an element-wise action across two arrays.

    Declaration
    public void ForEach(ICursorArray that, Action action)
    Parameters
    Type Name Description
    ICursorArray that

    An array of the same size as this. Can be the same object as this.

    Action action

    A delegate which accesses the array cursors.

    ForEach(Action)

    Invoke an action for each element of an array.

    Declaration
    public void ForEach(Action action)
    Parameters
    Type Name Description
    Action action

    A delegate which accesses the array cursor.

    GetEnumerator()

    Declaration
    public IEnumerator<CursorType> GetEnumerator()
    Returns
    Type Description
    IEnumerator<CursorType>

    GetLength(Int32)

    Declaration
    public int GetLength(int dimension)
    Parameters
    Type Name Description
    Int32 dimension
    Returns
    Type Description
    Int32

    IsCompatibleWith(ICursorArray)

    Declaration
    public bool IsCompatibleWith(ICursorArray that)
    Parameters
    Type Name Description
    ICursorArray that
    Returns
    Type Description
    Boolean

    IsCompatibleWith(Array)

    Declaration
    public bool IsCompatibleWith(Array that)
    Parameters
    Type Name Description
    Array that
    Returns
    Type Description
    Boolean

    LinearIndexToMultidimensionalIndex(Int32, IList<Int32>)

    Declaration
    public void LinearIndexToMultidimensionalIndex(int index, IList<int> indexList)
    Parameters
    Type Name Description
    Int32 index
    IList<Int32> indexList

    MoveTo(Int32)

    Position the cursor at a linear index.

    Declaration
    public void MoveTo(int index)
    Parameters
    Type Name Description
    Int32 index

    MoveTo(Int32[])

    Position the cursor at a multidimensional index.

    Declaration
    public void MoveTo(params int[] index)
    Parameters
    Type Name Description
    Int32[] index

    ReferenceClone()

    Declaration
    public virtual ICursor ReferenceClone()
    Returns
    Type Description
    ICursor

    UpdateCounts()

    Declaration
    protected void UpdateCounts()

    Explicit Interface Implementations

    ICursor.Count

    Declaration
    int ICursor.Count { get; }
    Returns
    Type Description
    Int32

    ICursorArray.Item[Int32]

    Declaration
    object ICursorArray.this[int index] { get; }
    Parameters
    Type Name Description
    Int32 index
    Returns
    Type Description
    Object

    ICursorArray.Item[Int32[]]

    Declaration
    object ICursorArray.this[params int[] index] { get; }
    Parameters
    Type Name Description
    Int32[] index
    Returns
    Type Description
    Object

    IEnumerable.GetEnumerator()

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    Implements

    ICursor
    System.ICloneable
    ICursorArray<T>
    System.Collections.Generic.IEnumerable<T>
    ICursorArray
    System.Collections.IEnumerable

    Extension Methods

    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<Int32, T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<Int32, T>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt32>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt64>)
    EnumerableExtensions.ValueEquals<T>(IEnumerable<T>, IEnumerable<T>)
    EnumerableExtensions.IndexOf<T>(IEnumerable<T>, T)
    EnumerableExtensions.IndexOf<T>(IEnumerable, T)
    EnumerableExtensions.FindIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.FindIndex<T>(IEnumerable, Predicate<T>)
    EnumerableExtensions.FindAllIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.IndexOfAll<T>(IEnumerable<T>, T)
    EnumerableExtensions.Skip<T>(IEnumerable<T>, Int32, out List<T>)
    EnumerableExtensions.CopyTo<T>(IEnumerable<T>, T[], Int32)
    EnumerableExtensions.ToReadOnlyList<T>(IEnumerable<T>)
    IEnumerableExensions.EnumerableReduce<T, TRes>(IEnumerable<T>, TRes, Func<TRes, T, TRes>, Func<TRes, T, Int32, TRes>)
    IEnumerableExensions.EnumerableSum<T>(IEnumerable<T>, Func<T, Double>)
    ReadOnlyArray.ToReadOnlyArray<T>(IEnumerable<T>)
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.