RecyclableList.Remove modified to allow removing the last item.

This commit is contained in:
Marek Lemańczyk committed 2023-03-05 18:51:06 +01:00
1 parent ec355160f9
commit 2558f57934
2 files changed
+34 -2

No files matched your search

+12 -1
View File
@@ -569,7 +569,18 @@ namespace Recyclable.Collections
? Array.IndexOf(_memoryBlocks[0], item, 0, (int)_longCount)
: DoIndexOf(item, _memoryBlocks, _lastBlockIndex, _blockSize, _nextItemIndex);
public bool Remove(T item) => throw new NotSupportedException();
public bool Remove(T item)
{
var itemIndex = LongIndexOf(item);
if (itemIndex >= 0)
{
RemoveAt(this, itemIndex, _defaultBlockArrayPool);
return true;
}
return false;
}
public void RemoveBlock(int index)
{
if (_blockSize < RecyclableDefaults.MinPooledArrayLength)