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

Corlib helper methods

This commit is contained in:
Brian Fiete 2022-08-26 15:42:35 -07:00
parent 6eddf12948
commit 74b73e5dc8
5 changed files with 116 additions and 2 deletions

View file

@ -551,6 +551,14 @@ namespace System.Collections
mSize = (.)size;
}
public void Resize(int newSize, T fillValue)
{
let prevSize = mSize;
Count = newSize;
for (int i = prevSize; i < newSize; i++)
mItems[i] = fillValue;
}
public Enumerator GetEnumerator()
{
return Enumerator(this);
@ -636,6 +644,19 @@ namespace System.Collections
return -1;
}
public void Set(Span<T> span)
{
Count = span.Length;
for (int i < mSize)
mItems[i] = span[i];
}
public void SetAll(T value)
{
for (int i < mSize)
mItems[i] = value;
}
public void Insert(int index, T item)
{
var item; // This creates a copy - required if item is a ref to an element