refactor: auto property on FastListOrdered

This commit is contained in:
2026-01-30 18:33:07 +03:00
parent 7675f9acac
commit 4e9fda3d7c

View File

@@ -16,8 +16,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
private readonly Func<TItem, TIndex> getIndexFunc = null!;
private readonly IComparer<TIndex> sortBy = null!;
private int count = 0;
public int Count => count;
public int Count { get; private set; } = 0;
public bool IsReadOnly { get; set; } = false;
@@ -35,10 +34,10 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
private (TIndex TIndex, int i) GetAt(Index index)
{
int actualIndex = index.IsFromEnd
? count - index.Value
? Count - index.Value
: index.Value;
if (actualIndex < 0 || actualIndex >= count)
if (actualIndex < 0 || actualIndex >= Count)
throw new IndexOutOfRangeException();
int leftIndex = actualIndex;
@@ -75,7 +74,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
items[key] = list = [];
list.Add(item);
count++;
Count++;
}
public void Insert(int index, TItem item)
@@ -88,7 +87,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
items[tIndex] = list = [];
list.Insert(index, item);
count++;
Count++;
}
public bool Remove(TItem item)
@@ -103,7 +102,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
if (!list.Remove(item))
return false;
count--;
Count--;
return true;
}
@@ -114,7 +113,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
(TIndex tIndex, int i) = GetAt(index);
items[tIndex].RemoveAt(i);
count--;
Count--;
}
public void Clear()
@@ -125,7 +124,7 @@ public class FastListOrdered<TIndex, TItem> : IList<TItem>, IReadOnlyList<TItem>
foreach ((TIndex index, FastList<TItem> list) in items)
list.Clear();
count = 0;
Count = 0;
}
public bool Contains(TItem item)