Show / Hide Table of Contents

Struct ReadOnlyArray<T>

A read-only array.
Implements
System.Collections.Generic.IReadOnlyList<T>
System.Collections.Generic.IReadOnlyCollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
System.IEquatable<ReadOnlyArray<T>>
System.Collections.IStructuralComparable
System.Collections.IStructuralEquatable
Inherited Members
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: ItsyBitsy.Collections
Assembly: ItsyBitsy.Collections.ReadOnlyArray.dll
Syntax
public struct ReadOnlyArray<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IEquatable<ReadOnlyArray<T>>, IStructuralComparable, IStructuralEquatable, IReadOnlyArray
Type Parameters
Name Description
T The type of the elements in the array.
Remarks
ReadOnlyArray<T> provides a common interface for read-only access to an array or an System.Collections.Immutable.ImmutableArray<T>. Unlike System.Collections.Immutable.ImmutableArray<T>, ReadOnlyArray<T> does not guarantee that the array cannot be mutated; it only guarantees that it cannot be used to mutate the array.

Fields

| Improve this Doc View Source

Empty

An empty array.
Declaration
public static readonly ReadOnlyArray<T> Empty
Field Value
Type Description
ReadOnlyArray<T>

Properties

| Improve this Doc View Source

IsDefault

Gets a value indicating that the array was not initialized.
Declaration
public bool IsDefault { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsDefaultOrEmpty

Gets a value indicating that the array was not initialized or is empty.
Declaration
public bool IsDefaultOrEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsEmpty

Gets a value indicating that the array is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Item[Int32]

Gets the element at the specified index in the array.
Declaration
public T this[int index] { get; }
Parameters
Type Name Description
System.Int32 index
Property Value
Type Description
T
| Improve this Doc View Source

Length

Gets the number of elements in the array.
Declaration
public int Length { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

As<TOther>()

Casts the array to an array of TOther.
Declaration
public ReadOnlyArray<TOther> As<TOther>()
    where TOther : class
Returns
Type Description
ReadOnlyArray<TOther>
Type Parameters
Name Description
TOther
| Improve this Doc View Source

AsMemory()

Creates a read-only memory region over the read-only array.
Declaration
public ReadOnlyMemory<T> AsMemory()
Returns
Type Description
System.ReadOnlyMemory<T>
| Improve this Doc View Source

AsSpan()

Creates a read-only span over the read-only array.
Declaration
public ReadOnlySpan<T> AsSpan()
Returns
Type Description
System.ReadOnlySpan<T>
| Improve this Doc View Source

CastArray<TOther>()

Casts the array to an array of TOther.
Declaration
public ReadOnlyArray<TOther> CastArray<TOther>()
    where TOther : class
Returns
Type Description
ReadOnlyArray<TOther>
Type Parameters
Name Description
TOther
| Improve this Doc View Source

CastUp<TDerived>(ReadOnlyArray<TDerived>)

Efficiently casts the array to an array of some type that T derives from.
Declaration
public static ReadOnlyArray<T> CastUp<TDerived>(ReadOnlyArray<TDerived> array)
    where TDerived : class, T
Parameters
Type Name Description
ReadOnlyArray<TDerived> array
Returns
Type Description
ReadOnlyArray<T>
Type Parameters
Name Description
TDerived
| Improve this Doc View Source

CopyTo(T[])

Copies the elements of the array to a specified array.
Declaration
public void CopyTo(T[] destination)
Parameters
Type Name Description
T[] destination
| Improve this Doc View Source

CopyTo(T[], Int32)

Copies the elements of the array to a specified array starting at a specified destination index.
Declaration
public void CopyTo(T[] destination, int destinationIndex)
Parameters
Type Name Description
T[] destination
System.Int32 destinationIndex
| Improve this Doc View Source

CopyTo(Int32, T[], Int32, Int32)

Copies the specified elements of the array to a specified array starting at a specified destination index.
Declaration
public void CopyTo(int sourceIndex, T[] destination, int destinationIndex, int length)
Parameters
Type Name Description
System.Int32 sourceIndex
T[] destination
System.Int32 destinationIndex
System.Int32 length
| Improve this Doc View Source

Equals(ReadOnlyArray<T>)

Determines if two arrays are the same array.
Declaration
public bool Equals(ReadOnlyArray<T> other)
Parameters
Type Name Description
ReadOnlyArray<T> other
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equals(Object)

Determines if two arrays are the same array.
Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetEnumerator()

Gets an enumerator that enumerates the elements of the array.
Declaration
public ReadOnlyArray<T>.Enumerator GetEnumerator()
Returns
Type Description
ReadOnlyArray.Enumerator<>
| Improve this Doc View Source

GetHashCode()

Gets a hash code for the array.
Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

IndexOf(T)

Searches the elements of the array for the first instance of a specified item.
Declaration
public int IndexOf(T item)
Parameters
Type Name Description
T item
Returns
Type Description
System.Int32
| Improve this Doc View Source

IndexOf(T, Int32)

Searches the specified elements of the array for the first instance of a specified item.
Declaration
public int IndexOf(T item, int startIndex)
Parameters
Type Name Description
T item
System.Int32 startIndex
Returns
Type Description
System.Int32
| Improve this Doc View Source

IndexOf(T, Int32, Int32)

Searches the specified elements of the array for the first instance of a specified item.
Declaration
public int IndexOf(T item, int startIndex, int count)
Parameters
Type Name Description
T item
System.Int32 startIndex
System.Int32 count
Returns
Type Description
System.Int32
| Improve this Doc View Source

ItemRef(Int32)

Gets a read-only reference to the element at the specified index in the array.
Declaration
public T ItemRef(int index)
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
T
| Improve this Doc View Source

LastIndexOf(T)

Searches the elements of the array for the last instance of a specified item.
Declaration
public int LastIndexOf(T item)
Parameters
Type Name Description
T item
Returns
Type Description
System.Int32
| Improve this Doc View Source

LastIndexOf(T, Int32)

Searches the specified elements of the array for the last instance of a specified item.
Declaration
public int LastIndexOf(T item, int startIndex)
Parameters
Type Name Description
T item
System.Int32 startIndex
Returns
Type Description
System.Int32
| Improve this Doc View Source

LastIndexOf(T, Int32, Int32)

Searches the specified elements of the array for the last instance of a specified item.
Declaration
public int LastIndexOf(T item, int startIndex, int count)
Parameters
Type Name Description
T item
System.Int32 startIndex
System.Int32 count
Returns
Type Description
System.Int32
| Improve this Doc View Source

ToImmutableArray()

Creates an immutable array from the current contents of the array.
Declaration
public ImmutableArray<T> ToImmutableArray()
Returns
Type Description
System.Collections.Immutable.ImmutableArray<T>
Remarks
ToImmutableArray() always returns a new System.Collections.Immutable.ImmutableArray<T> even if the ReadOnlyArray<T> was constructed from an System.Collections.Immutable.ImmutableArray<T>.

Operators

| Improve this Doc View Source

Equality(ReadOnlyArray<T>, ReadOnlyArray<T>)

Determines if two arrays are the same array.
Declaration
public static bool operator ==(ReadOnlyArray<T> left, ReadOnlyArray<T> right)
Parameters
Type Name Description
ReadOnlyArray<T> left
ReadOnlyArray<T> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equality(ReadOnlyArray<T>, Nullable<ReadOnlyArray<T>>)

Determines if two arrays are the same array.
Declaration
public static bool operator ==(ReadOnlyArray<T> left, ReadOnlyArray<T>? right)
Parameters
Type Name Description
ReadOnlyArray<T> left
System.Nullable<ReadOnlyArray<T>> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equality(Nullable<ReadOnlyArray<T>>, ReadOnlyArray<T>)

Determines if two arrays are the same array.
Declaration
public static bool operator ==(ReadOnlyArray<T>? left, ReadOnlyArray<T> right)
Parameters
Type Name Description
System.Nullable<ReadOnlyArray<T>> left
ReadOnlyArray<T> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Equality(Nullable<ReadOnlyArray<T>>, Nullable<ReadOnlyArray<T>>)

Determines if two arrays are the same array.
Declaration
public static bool operator ==(ReadOnlyArray<T>? left, ReadOnlyArray<T>? right)
Parameters
Type Name Description
System.Nullable<ReadOnlyArray<T>> left
System.Nullable<ReadOnlyArray<T>> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Implicit(T[] to ReadOnlyArray<T>)

Converts an array to a ReadOnlyArray<T>.
Declaration
public static implicit operator ReadOnlyArray<T>(T[] array)
Parameters
Type Name Description
T[] array
Returns
Type Description
ReadOnlyArray<T>
| Improve this Doc View Source

Implicit(ImmutableArray<T> to ReadOnlyArray<T>)

Converts an System.Collections.Immutable.ImmutableArray<T> to a ReadOnlyArray<T>.
Declaration
public static implicit operator ReadOnlyArray<T>(ImmutableArray<T> array)
Parameters
Type Name Description
System.Collections.Immutable.ImmutableArray<T> array
Returns
Type Description
ReadOnlyArray<T>
| Improve this Doc View Source

Inequality(ReadOnlyArray<T>, ReadOnlyArray<T>)

Determines if two arrays are not the same array.
Declaration
public static bool operator !=(ReadOnlyArray<T> left, ReadOnlyArray<T> right)
Parameters
Type Name Description
ReadOnlyArray<T> left
ReadOnlyArray<T> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Inequality(ReadOnlyArray<T>, Nullable<ReadOnlyArray<T>>)

Determines if two arrays are not the same array.
Declaration
public static bool operator !=(ReadOnlyArray<T> left, ReadOnlyArray<T>? right)
Parameters
Type Name Description
ReadOnlyArray<T> left
System.Nullable<ReadOnlyArray<T>> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Inequality(Nullable<ReadOnlyArray<T>>, ReadOnlyArray<T>)

Determines if two arrays are not the same array.
Declaration
public static bool operator !=(ReadOnlyArray<T>? left, ReadOnlyArray<T> right)
Parameters
Type Name Description
System.Nullable<ReadOnlyArray<T>> left
ReadOnlyArray<T> right
Returns
Type Description
System.Boolean
| Improve this Doc View Source

Inequality(Nullable<ReadOnlyArray<T>>, Nullable<ReadOnlyArray<T>>)

Determines if two arrays are not the same array.
Declaration
public static bool operator !=(ReadOnlyArray<T>? left, ReadOnlyArray<T>? right)
Parameters
Type Name Description
System.Nullable<ReadOnlyArray<T>> left
System.Nullable<ReadOnlyArray<T>> right
Returns
Type Description
System.Boolean

Explicit Interface Implementations

| Improve this Doc View Source

IEnumerable<T>.GetEnumerator()

Declaration
IEnumerator<T> IEnumerable<T>.GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>
| Improve this Doc View Source

IReadOnlyCollection<T>.Count

Declaration
int IReadOnlyCollection<T>.Count { get; }
Returns
Type Description
System.Int32
| Improve this Doc View Source

IReadOnlyList<T>.Item[Int32]

Declaration
T IReadOnlyList<T>.this[int index] { get; }
Parameters
Type Name Description
System.Int32 index
Returns
Type Description
T
| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator
| Improve this Doc View Source

IStructuralComparable.CompareTo(Object, IComparer)

Declaration
int IStructuralComparable.CompareTo(object other, IComparer comparer)
Parameters
Type Name Description
System.Object other
System.Collections.IComparer comparer
Returns
Type Description
System.Int32
| Improve this Doc View Source

IStructuralEquatable.Equals(Object, IEqualityComparer)

Declaration
bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
Parameters
Type Name Description
System.Object other
System.Collections.IEqualityComparer comparer
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IStructuralEquatable.GetHashCode(IEqualityComparer)

Declaration
int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
Parameters
Type Name Description
System.Collections.IEqualityComparer comparer
Returns
Type Description
System.Int32

Implements

System.Collections.Generic.IReadOnlyList<T>
System.Collections.Generic.IReadOnlyCollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
System.IEquatable<T>
System.Collections.IStructuralComparable
System.Collections.IStructuralEquatable
  • Improve this Doc
  • View Source
Back to top Generated by DocFX