diff --git a/BeefLibs/corlib/src/Collections/List.bf b/BeefLibs/corlib/src/Collections/List.bf index 5f6a020e..2455a284 100644 --- a/BeefLibs/corlib/src/Collections/List.bf +++ b/BeefLibs/corlib/src/Collections/List.bf @@ -318,6 +318,8 @@ namespace System.Collections } } + public Span.ReverseEnumerator Reversed => Span(mItems, mSize).Reversed; + protected virtual T* Alloc(int size) { return Internal.AllocRawArrayUnmarked(size); @@ -418,7 +420,7 @@ namespace System.Collections Add(item); } - public Span GetRange(int offset) + public Span GetRange(int offset = 0) { Debug.Assert((uint)offset <= (uint)mSize); return .(mItems + offset, mSize - offset); diff --git a/BeefLibs/corlib/src/Range.bf b/BeefLibs/corlib/src/Range.bf index 2ff245fc..e1075beb 100644 --- a/BeefLibs/corlib/src/Range.bf +++ b/BeefLibs/corlib/src/Range.bf @@ -444,6 +444,7 @@ namespace System [Inline] public this(int start, int end, bool isClosed=true) { + Debug.Assert(end >= start); mStart = .FromFront(start); mEnd = .FromFront(end); mIsClosed = isClosed; diff --git a/BeefLibs/corlib/src/Span.bf b/BeefLibs/corlib/src/Span.bf index c8f24d2d..0a356733 100644 --- a/BeefLibs/corlib/src/Span.bf +++ b/BeefLibs/corlib/src/Span.bf @@ -23,6 +23,7 @@ namespace System } mPtr = &array.[Friend]GetRef(0); mLength = array.[Friend]mLength; + Debug.Assert(mLength >= 0); } public this(T[] array, int index) @@ -35,10 +36,12 @@ namespace System } mPtr = &array[index]; mLength = array.[Friend]mLength - index; + Debug.Assert(mLength >= 0); } public this(T[] array, int index, int length) { + Debug.Assert(length >= 0); if (array == null) { Debug.Assert(index == 0 && length == 0); @@ -54,6 +57,7 @@ namespace System public this(T* memory, int length) { + Debug.Assert(length >= 0); mPtr = memory; mLength = length; }