mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 05:14:10 +02:00
Added additional Span length asserts. Added Reversed to List
This commit is contained in:
parent
078727c4a7
commit
f0a31a0f55
3 changed files with 8 additions and 1 deletions
|
@ -318,6 +318,8 @@ namespace System.Collections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Span<T>.ReverseEnumerator Reversed => Span<T>(mItems, mSize).Reversed;
|
||||||
|
|
||||||
protected virtual T* Alloc(int size)
|
protected virtual T* Alloc(int size)
|
||||||
{
|
{
|
||||||
return Internal.AllocRawArrayUnmarked<T>(size);
|
return Internal.AllocRawArrayUnmarked<T>(size);
|
||||||
|
@ -418,7 +420,7 @@ namespace System.Collections
|
||||||
Add(item);
|
Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span<T> GetRange(int offset)
|
public Span<T> GetRange(int offset = 0)
|
||||||
{
|
{
|
||||||
Debug.Assert((uint)offset <= (uint)mSize);
|
Debug.Assert((uint)offset <= (uint)mSize);
|
||||||
return .(mItems + offset, mSize - offset);
|
return .(mItems + offset, mSize - offset);
|
||||||
|
|
|
@ -444,6 +444,7 @@ namespace System
|
||||||
[Inline]
|
[Inline]
|
||||||
public this(int start, int end, bool isClosed=true)
|
public this(int start, int end, bool isClosed=true)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(end >= start);
|
||||||
mStart = .FromFront(start);
|
mStart = .FromFront(start);
|
||||||
mEnd = .FromFront(end);
|
mEnd = .FromFront(end);
|
||||||
mIsClosed = isClosed;
|
mIsClosed = isClosed;
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace System
|
||||||
}
|
}
|
||||||
mPtr = &array.[Friend]GetRef(0);
|
mPtr = &array.[Friend]GetRef(0);
|
||||||
mLength = array.[Friend]mLength;
|
mLength = array.[Friend]mLength;
|
||||||
|
Debug.Assert(mLength >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(T[] array, int index)
|
public this(T[] array, int index)
|
||||||
|
@ -35,10 +36,12 @@ namespace System
|
||||||
}
|
}
|
||||||
mPtr = &array[index];
|
mPtr = &array[index];
|
||||||
mLength = array.[Friend]mLength - index;
|
mLength = array.[Friend]mLength - index;
|
||||||
|
Debug.Assert(mLength >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public this(T[] array, int index, int length)
|
public this(T[] array, int index, int length)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(length >= 0);
|
||||||
if (array == null)
|
if (array == null)
|
||||||
{
|
{
|
||||||
Debug.Assert(index == 0 && length == 0);
|
Debug.Assert(index == 0 && length == 0);
|
||||||
|
@ -54,6 +57,7 @@ namespace System
|
||||||
|
|
||||||
public this(T* memory, int length)
|
public this(T* memory, int length)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(length >= 0);
|
||||||
mPtr = memory;
|
mPtr = memory;
|
||||||
mLength = length;
|
mLength = length;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue