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.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)
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. |
Fields
|
Improve this Doc
View Source
Empty
An empty array.
Declaration
public static readonly ReadOnlyArray<T> Empty
Field Value
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
|
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 Parameters
|
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 Parameters
|
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
Returns
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
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
|
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
|
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> |
|
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
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
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
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
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Implicit(T[] to ReadOnlyArray<T>)
Declaration
public static implicit operator ReadOnlyArray<T>(T[] array)
Parameters
Type |
Name |
Description |
T[] |
array |
|
Returns
|
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
|
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
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
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
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
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
|
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