10public static class ImmutableArray
21 T[] items =
new T[1] {
item };
64 if (items ==
null || items.Length == 0)
68 T[]
array =
new T[items.Length];
83 for (
int i = 0; i <
array.Length; i++)
110 int length = items.Length;
116 for (
int i = 0; i <
array.Length; i++)
134 for (
int i = 0; i <
array.Length; i++)
144 int length = items.Length;
150 for (
int i = 0; i <
array.Length; i++)
168 for (
int i = 0; i <
array.Length; i++)
191 return CreateRange(items);
220[DebuggerDisplay(
"{DebuggerDisplay,nq}")]
222public readonly
struct ImmutableArray<T> :
IReadOnlyList<T>,
IEnumerable<T>,
IEnumerable,
IReadOnlyCollection<T>,
IList<T>,
ICollection<T>,
IEquatable<ImmutableArray<T>>,
IList,
ICollection,
IImmutableArray,
IStructuralComparable,
IStructuralEquatable,
IImmutableList<T>
397 foreach (T
item in items)
407 Count += items.Length;
415 Count += items.Length;
436 if (items.array !=
null)
444 if (items.array !=
null)
607 T val = elements[num];
608 elements[num] = elements[
num2];
609 elements[
num2] = val;
652 for (
int i = 0; i <
Count; i++)
654 yield return this[i];
674 for (
int i = 0; i <
length; i++)
676 elements[
count + i] = (
T)(
object)items[i];
733 if ((uint)num <= (uint)
num2)
736 return (uint)num < (uint)
num2;
752 if (
array.Length != 0)
815 bool IList.IsFixedSize =>
true;
818 bool IList.IsReadOnly =>
true;
821 int ICollection.Count
832 bool ICollection.IsSynchronized =>
true;
835 object ICollection.SyncRoot
872 return array.Length == 0;
897 return immutableArray.array.Length == 0;
914 return $"Length = {immutableArray.Length}";
916 return "Uninitialized";
1042 T[]
array =
new T[immutableArray.Length + 1];
1058 result.ThrowNullRefIfNotInitialized();
1061 if (result.Length == 0)
1075 if (
index != result.Length)
1082 foreach (T
item in items)
1093 result.ThrowNullRefIfNotInitialized();
1094 items.ThrowNullRefIfNotInitialized();
1104 T[]
array =
new T[result.Length + items.Length];
1109 if (
index != result.Length)
1174 result.ThrowNullRefIfNotInitialized();
1178 return result.RemoveAt(num);
1191 result.ThrowNullRefIfNotInitialized();
1215 foreach (T
item in items)
1234 Requires.NotNull(items.array,
"items");
1237 result.ThrowNullRefIfNotInitialized();
1240 if (items.Length == 1)
1250 result.ThrowNullRefIfNotInitialized();
1257 for (
int i = 0; i < result.array.Length; i++)
1259 if (
match(result.array[i]))
1272 return result.RemoveAtRange(
list);
1302 result.ThrowNullRefIfNotInitialized();
1314 if (
comparer.Compare(result.array[i - 1], result.array[i]) > 0)
1322 T[]
array =
new T[result.Length];
1553 result.ThrowNullRefIfNotInitialized();
1583 return left.Equals(right);
1589 return !left.Equals(right);
1594 return left.GetValueOrDefault().Equals(right.GetValueOrDefault());
1599 return !left.GetValueOrDefault().Equals(right.GetValueOrDefault());
1631 if (items.Length == 0)
1675 T[]
items2 = (T[])(
object)items.array;
static void Sort(Array array)
int IList. IndexOf(object value)
static int LastIndexOf(Array array, object? value)
static unsafe void Clear(Array array)
static int BinarySearch(Array array, object? value)
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
Enumerator GetEnumerator()
void Add(TKey key, TValue value)
void Insert(int index, T item)
int LastIndexOf(T item, int startIndex)
void Sort(IComparer< T >? comparer)
void CopyTo(T[] array, int index)
int LastIndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
void EnsureCapacity(int capacity)
void AddRange(params T[] items)
void AddRange(ImmutableArray< T > items, int length)
void Sort(int index, int count, IComparer< T >? comparer)
ImmutableArray< T > ToImmutable()
void AddRange(IEnumerable< T > items)
int IndexOf(T item, int startIndex, int count)
void AddRange(Builder items)
static void ThrowIndexOutOfRangeException()
int IndexOf(T item, int startIndex)
ref readonly T ItemRef(int index)
void AddRange< TDerived >(TDerived[] items)
int IndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
void AddRange(T[] items, int length)
void Sort(Comparison< T > comparison)
IEnumerator< T > GetEnumerator()
ImmutableArray< T > MoveToImmutable()
int LastIndexOf(T item, int startIndex, int count)
void AddRange(ImmutableArray< T > items)
static readonly IEnumerator< T > s_EmptyEnumerator
static IEnumerator< T > Create(T[] array)
EnumeratorObject(T[] array)
object IEnumerator. Current
static ImmutableArray< TResult > CreateRange< TSource, TResult >(ImmutableArray< TSource > items, Func< TSource, TResult > selector)
ImmutableArray< T > SetItem(int index, T item)
void CopyTo(int sourceIndex, T[] destination, int destinationIndex, int length)
ImmutableArray< T > Sort(Comparison< T > comparison)
ref readonly T ItemRef(int index)
ImmutableArray< T > Remove(T item)
int IndexOf(T item, int startIndex)
ImmutableArray< TOther > CastArray< TOther >()
void ThrowNullRefIfNotInitialized()
ImmutableArray< T > RemoveRange(IEnumerable< T > items, IEqualityComparer< T >? equalityComparer)
static ImmutableArray< TSource > ToImmutableArray< TSource >(this IEnumerable< TSource > items)
static int BinarySearch< T >(this ImmutableArray< T > array, T value)
ImmutableArray< T > RemoveRange(ImmutableArray< T > items)
int LastIndexOf(T item, int startIndex, int count)
static readonly byte[] TwoElementArray
override bool Equals([NotNullWhen(true)] object? obj)
static ImmutableArray< T >.Builder CreateBuilder< T >()
ImmutableArray< T > RemoveRange(IEnumerable< T > items)
static ImmutableArray< T > CastUp< TDerived >(ImmutableArray< TDerived > items)
void CopyTo(T[] destination)
ImmutableArray< T > Clear()
static bool operator==(ImmutableArray< T > left, ImmutableArray< T > right)
override int GetHashCode()
ReadOnlyMemory< T > AsMemory()
static ImmutableArray< T > CreateRange< T >(IEnumerable< T > items)
Enumerator GetEnumerator()
ImmutableArray< T > Sort(IComparer< T >? comparer)
ImmutableArray< T > RemoveAt(int index)
ImmutableArray< T > AddRange(ImmutableArray< T > items)
static ImmutableArray< TResult > CreateRange< TSource, TArg, TResult >(ImmutableArray< TSource > items, Func< TSource, TArg, TResult > selector, TArg arg)
int LastIndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
int IndexOf(T item, int startIndex, IEqualityComparer< T >? equalityComparer)
ImmutableArray< T > Replace(T oldValue, T newValue)
int IndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
int IndexOf(T item, int startIndex, int count)
ImmutableArray< T > RemoveRange(ImmutableArray< T > items, IEqualityComparer< T >? equalityComparer)
ImmutableArray< T > InsertRange(int index, IEnumerable< T > items)
ImmutableArray< T > RemoveRange(int index, int length)
void CopyTo(T[] destination, int destinationIndex)
ImmutableArray< T > Add(T item)
ImmutableArray< T > InsertRange(int index, ImmutableArray< T > items)
ImmutableArray< T > Replace(T oldValue, T newValue, IEqualityComparer< T >? equalityComparer)
ImmutableArray< TOther > As< TOther >()
ImmutableArray< T > Sort()
IEnumerable< TResult > OfType< TResult >()
void ThrowInvalidOperationIfNotInitialized()
ImmutableArray< T > Remove(T item, IEqualityComparer< T >? equalityComparer)
static bool operator!=(ImmutableArray< T > left, ImmutableArray< T > right)
static readonly ImmutableArray< T > Empty
ImmutableArray< T >.Builder ToBuilder()
ReadOnlySpan< T > AsSpan()
ImmutableArray< T > AddRange(IEnumerable< T > items)
ImmutableArray< T > RemoveAll(Predicate< T > match)
ImmutableArray< T > Sort(int index, int count, IComparer< T >? comparer)
ImmutableArray< T > Insert(int index, T item)
static ImmutableArray< T > Create< T >()
ImmutableArray(T[]? items)
ImmutableArray< T > RemoveAtRange(ICollection< int > indicesToRemove)
bool Equals(ImmutableArray< T > other)
int LastIndexOf(T item, int startIndex)
Array? IImmutableArray. Array
static void Range(bool condition, string? parameterName, string? message=null)
static byte Max(byte val1, byte val2)
static string InvalidOperationOnDefaultArray
static string CapacityMustEqualCountOnMove
static string ArrayLengthsNotEqual
static string CapacityMustBeGreaterThanOrEqualToCount
static string ArrayInitializedStateNotEqual
static string CannotFindOldValue
void CopyTo(Array array, int index)
IEnumerator GetEnumerator()
void Insert(int index, object? value)
bool Contains(object? value)
void Remove(object? value)
int IndexOf(object? value)
int CompareTo(object? other, IComparer comparer)
int GetHashCode(IEqualityComparer comparer)
bool Equals(object? other, IEqualityComparer comparer)