1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Merge pull request #963 from EinBurgbauer/master

list.RemoveRange fix, RemoveRangeFast
This commit is contained in:
Brian Fiete 2021-03-20 07:01:10 -04:00 committed by GitHub
commit 10e2a56530
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -578,7 +578,7 @@ namespace System.Collections
public void RemoveRange(int index, int count)
{
Debug.Assert((uint)index + (uint)count <= (uint)mSize);
if (index + count < mSize - 1)
if (index + count <= mSize - 1)
{
for (int i = index; i < mSize - count; i++)
mItems[i] = mItems[i + count];
@ -589,12 +589,29 @@ namespace System.Collections
#endif
}
/// Will change the order of items in the list
public void RemoveAtFast(int index)
{
Debug.Assert((uint32)index < (uint32)mSize);
mSize--;
if (mSize > 0)
mItems[index] = mItems[mSize];
mItems[index] = mItems[mSize];
#if VERSION_LIST
mVersion++;
#endif
}
/// Will change the order of items in the list
public void RemoveRangeFast(int index, int count)
{
Debug.Assert((uint)index + (uint)count <= (uint)mSize);
if (index + count <= mSize - 1)
{
int moveCount = Math.Min(count, mSize - (index + count));
for (int i < moveCount)
mItems[index + i] = mItems[mSize - moveCount + i];
}
mSize -= (.)count;
#if VERSION_LIST
mVersion++;
#endif