11public static class ImmutableList
131[DebuggerDisplay(
"Count = {Count}")]
133public sealed class ImmutableList<T> :
IImmutableList<T>,
IReadOnlyList<T>,
IEnumerable<T>,
IEnumerable,
IReadOnlyCollection<T>,
IList<T>,
ICollection<T>,
IList,
ICollection,
IOrderedCollection<T>,
IImmutableListQueries<T>,
IStrongEnumerable<T, ImmutableList<T>.Enumerator>
135 [DebuggerDisplay(
"Count = {Count}")]
184 bool IList.IsFixedSize =>
false;
186 bool IList.IsReadOnly =>
false;
201 bool ICollection.IsSynchronized =>
false;
204 object ICollection.SyncRoot
627 value.ClearFastWhenEmpty();
665 stack.ClearFastWhenEmpty();
727 while (!
node.IsEmpty)
736 [DebuggerDisplay(
"{_key}")]
867 int num = (
length - 1) / 2;
871 return new Node(items[
start +
num2], left, right, frozen:
true);
882 if (!
node.IsBalanced)
884 return node.BalanceRight();
900 if (!
node.IsBalanced)
902 return node.BalanceLeft();
908 if (!
node2.IsBalanced)
910 return node2.BalanceRight();
924 return node.BalanceMany();
946 return node.BalanceMany();
970 while (!
node2._left.IsEmpty)
988 if (!
node.IsEmpty && !
node.IsBalanced)
990 return node.Balance();
1202 array[num++] = current;
1265 if (!
match(current))
1495 while (!
node.IsBalanced)
1497 if (
node.IsRightHeavy)
1500 node.MutateLeft(
node._left.BalanceMany());
1505 node.MutateRight(
node._right.BalanceMany());
1517 return new Node(
_key, left, right);
1560 return 1 + left._count + right.
_count;
1612 object ICollection.SyncRoot =>
this;
1615 bool ICollection.IsSynchronized =>
true;
1635 bool IList.IsFixedSize =>
true;
1637 bool IList.IsReadOnly =>
true;
1772 foreach (T
item in items.GetEnumerableDisposable<T,
Enumerator>())
2142 return default(T) ==
null;
static void Sort(Array array)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(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 Sort(IComparer< T >? comparer)
T? FindLast(Predicate< T > match)
void InsertRange(int index, IEnumerable< T > items)
void Insert(int index, T item)
bool TrueForAll(Predicate< T > match)
Builder(ImmutableList< T > list)
T? Find(Predicate< T > match)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
bool Exists(Predicate< T > match)
int FindLastIndex(Predicate< T > match)
ImmutableList< T > ToImmutable()
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
void Reverse(int index, int count)
ImmutableList< T > GetRange(int index, int count)
int IndexOf(T item, int index)
void Sort(int index, int count, IComparer< T >? comparer)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
void ForEach(Action< T > action)
int LastIndexOf(T item, int startIndex, int count, IEqualityComparer< T >? equalityComparer)
ImmutableList< T >.Enumerator GetEnumerator()
void CopyTo(T[] array, int arrayIndex)
int FindIndex(int startIndex, int count, Predicate< T > match)
ImmutableList< TOutput > ConvertAll< TOutput >(Func< T, TOutput > converter)
int IndexOf(T item, int index, int count)
void Sort(Comparison< T > comparison)
int BinarySearch(T item, IComparer< T >? comparer)
int RemoveAll(Predicate< T > match)
ImmutableList< T > _immutable
ref readonly T ItemRef(int index)
int FindLastIndex(int startIndex, Predicate< T > match)
int LastIndexOf(T item, int startIndex)
ImmutableList< T > FindAll(Predicate< T > match)
int FindIndex(int startIndex, Predicate< T > match)
void CopyTo(int index, T[] array, int arrayIndex, int count)
void AddRange(IEnumerable< T > items)
int FindIndex(Predicate< T > match)
int LastIndexOf(T item, int startIndex, int count)
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
static bool Contains(Node node, T value, IEqualityComparer< T > equalityComparer)
int FindLastIndex(Predicate< T > match)
int LastIndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
Node Reverse(int index, int count)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
int IndexOf(T item, IEqualityComparer< T >? equalityComparer)
int FindLastIndex(int startIndex, Predicate< T > match)
void CopyTo(T[] array, int arrayIndex)
Enumerator GetEnumerator()
int FindIndex(Predicate< T > match)
ImmutableList< T > FindAll(Predicate< T > match)
static Node NodeTreeFromList(IOrderedCollection< T > items, int start, int length)
int FindIndex(int startIndex, Predicate< T > match)
static readonly Node EmptyNode
T? FindLast(Predicate< T > match)
Node AddRange(IEnumerable< T > keys)
static Node CreateLeaf(T key)
static byte ParentHeight(Node left, Node right)
Node Sort(int index, int count, IComparer< T >? comparer)
Node MutateLeft(Node left)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
Node Sort(IComparer< T >? comparer)
Node MutateBoth(Node left, Node right)
Enumerator GetEnumerator(Builder builder)
Node InsertRange(int index, IEnumerable< T > keys)
int FindIndex(int startIndex, int count, Predicate< T > match)
void CopyTo(Array array, int arrayIndex)
static int ParentCount(Node left, Node right)
T? Find(Predicate< T > match)
Node Insert(int index, T key)
Node Sort(Comparison< T > comparison)
void CopyTo(int index, T[] array, int arrayIndex, int count)
Node RemoveAll(Predicate< T > match)
bool Exists(Predicate< T > match)
static Node CreateRange(IEnumerable< T > keys)
Node ReplaceAt(int index, T value)
ImmutableList< TOutput >.Node ConvertAll< TOutput >(Func< T, TOutput > converter)
ref readonly T ItemRefUnchecked(int index)
bool Contains(T item, IEqualityComparer< T > equalityComparer)
bool TrueForAll(Predicate< T > match)
Node MutateRight(Node right)
ref readonly T ItemRef(int index)
Node(T key, Node left, Node right, bool frozen=false)
ImmutableList< T > Sort(Comparison< T > comparison)
ImmutableList< T > Insert(int index, T item)
ImmutableList< T > InsertRange(int index, IEnumerable< T > items)
ImmutableList< T > Add(T value)
ImmutableList< T > RemoveAt(int index)
ImmutableList< T > Remove(T value)
ImmutableList< T > RemoveAll(Predicate< T > match)
int IndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
static ImmutableList< TSource > ToImmutableList< TSource >(this IEnumerable< TSource > source)
ImmutableList< T > Replace(T oldValue, T newValue)
int FindLastIndex(int startIndex, Predicate< T > match)
ref readonly T ItemRef(int index)
int FindIndex(int startIndex, int count, Predicate< T > match)
ImmutableList< T > GetRange(int index, int count)
int FindLastIndex(int startIndex, int count, Predicate< T > match)
static int IndexOf< T >(this IImmutableList< T > list, T item)
static readonly ImmutableList< T > Empty
IEnumerator< T > IEnumerable< T >. GetEnumerator()
static int LastIndexOf< T >(this IImmutableList< T > list, T item)
ImmutableList< T > RemoveRange(int index, int count)
static ImmutableList< T > CreateRange< T >(IEnumerable< T > items)
T? Find(Predicate< T > match)
T? FindLast(Predicate< T > match)
static ImmutableList< T > CreateRange(IEnumerable< T > items)
ImmutableList< T > Sort()
int BinarySearch(int index, int count, T item, IComparer< T >? comparer)
static ImmutableList< T >.Builder CreateBuilder< T >()
int FindIndex(Predicate< T > match)
ImmutableList< T > FindAll(Predicate< T > match)
bool Exists(Predicate< T > match)
int BinarySearch(T item, IComparer< T >? comparer)
ImmutableList< T > Remove(T value, IEqualityComparer< T >? equalityComparer)
ImmutableList< T > AddRange(IEnumerable< T > items)
Enumerator GetEnumerator()
static ImmutableList< T > Create< T >()
ImmutableList< T > Replace(T oldValue, T newValue, IEqualityComparer< T >? equalityComparer)
void ForEach(Action< T > action)
ImmutableList< T > Clear()
int FindLastIndex(Predicate< T > match)
ImmutableList< T > Sort(int index, int count, IComparer< T >? comparer)
static bool TryCastToImmutableList(IEnumerable< T > sequence, [NotNullWhen(true)] out ImmutableList< T > other)
ImmutableList< T > Sort(IComparer< T >? comparer)
static IImmutableList< T > Remove< T >(this IImmutableList< T > list, T value)
ImmutableList< T > RemoveRange(IEnumerable< T > items)
void CopyTo(T[] array, int arrayIndex)
static IImmutableList< T > RemoveRange< T >(this IImmutableList< T > list, IEnumerable< T > items)
int LastIndexOf(T item, int index, int count, IEqualityComparer< T >? equalityComparer)
static bool IsCompatibleObject(object value)
ImmutableList< T > Reverse()
void CopyTo(int index, T[] array, int arrayIndex, int count)
ImmutableList< T > SetItem(int index, T value)
ImmutableList< TOutput > ConvertAll< TOutput >(Func< T, TOutput > converter)
ImmutableList< T > Reverse(int index, int count)
int FindIndex(int startIndex, Predicate< T > match)
static ImmutableList< T > WrapNode(Node root)
static IImmutableList< T > Replace< T >(this IImmutableList< T > list, T oldValue, T newValue)
bool TrueForAll(Predicate< T > match)
ImmutableList< T > RemoveRange(IEnumerable< T > items, IEqualityComparer< T >? equalityComparer)
ImmutableList< T > Wrap(Node root)
static void Range(bool condition, string? parameterName, string? message=null)
static void Argument(bool condition, string? parameterName, string? message)
static byte Max(byte val1, byte val2)
static string CollectionModifiedDuringEnumeration
static string CannotFindOldValue
static int CompareExchange(ref int location1, int value, int comparand)
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)
SecurePooledObject< Stack< RefAsValueType< Node > > > _stack
int _enumeratingBuilderVersion
readonly Builder _builder
Node NextBranch(Node node)
static readonly SecureObjectPool< Stack< RefAsValueType< Node > >, Enumerator > s_EnumeratingStacks
Enumerator(Node root, Builder? builder=null, int startIndex=-1, int count=-1, bool reversed=false)
Node PreviousBranch(Node node)
object? IEnumerator. Current