mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 06:44:10 +02:00
Merge pull request #963 from EinBurgbauer/master
list.RemoveRange fix, RemoveRangeFast
This commit is contained in:
commit
10e2a56530
1 changed files with 19 additions and 2 deletions
|
@ -578,7 +578,7 @@ namespace System.Collections
|
||||||
public void RemoveRange(int index, int count)
|
public void RemoveRange(int index, int count)
|
||||||
{
|
{
|
||||||
Debug.Assert((uint)index + (uint)count <= (uint)mSize);
|
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++)
|
for (int i = index; i < mSize - count; i++)
|
||||||
mItems[i] = mItems[i + count];
|
mItems[i] = mItems[i + count];
|
||||||
|
@ -589,6 +589,7 @@ namespace System.Collections
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Will change the order of items in the list
|
||||||
public void RemoveAtFast(int index)
|
public void RemoveAtFast(int index)
|
||||||
{
|
{
|
||||||
Debug.Assert((uint32)index < (uint32)mSize);
|
Debug.Assert((uint32)index < (uint32)mSize);
|
||||||
|
@ -600,6 +601,22 @@ namespace System.Collections
|
||||||
#endif
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
public void Sort(Comparison<T> comp)
|
public void Sort(Comparison<T> comp)
|
||||||
{
|
{
|
||||||
var sorter = Sorter<T, void>(mItems, null, mSize, comp);
|
var sorter = Sorter<T, void>(mItems, null, mSize, comp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue