From 9e51d177e87f3e8a3604764d327d3393b112c3c0 Mon Sep 17 00:00:00 2001 From: Yoh Deadfall Date: Mon, 24 Apr 2023 20:24:58 +0300 Subject: [PATCH] Added indexer for immutable sequence --- WabiSabi/Collections/ImmutableValueSequence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WabiSabi/Collections/ImmutableValueSequence.cs b/WabiSabi/Collections/ImmutableValueSequence.cs index 89e1055..4bee01c 100644 --- a/WabiSabi/Collections/ImmutableValueSequence.cs +++ b/WabiSabi/Collections/ImmutableValueSequence.cs @@ -8,7 +8,7 @@ namespace WabiSabi.Collections; /// it can be compared with other sequences and the equality of two sequences is based on the /// equality of the elements. /// -public readonly struct ImmutableValueSequence : IReadOnlyCollection, IEquatable> where T : IEquatable +public readonly struct ImmutableValueSequence : IReadOnlyList, IEquatable> where T : IEquatable { private readonly ImmutableArray _elements; @@ -19,6 +19,8 @@ public ImmutableValueSequence(IEnumerable sequence) public static ImmutableValueSequence Empty { get; } = new(); + public T this[int index] => _elements[index]; + public int Count => _elements.Length; public ImmutableArray.Enumerator GetEnumerator() => _elements.GetEnumerator();