1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 16:40:26 +02:00
Beef/IDE/mintest/minlib/src/System/Range.bf
2021-10-24 09:00:04 -07:00

89 lines
1.3 KiB
Beef

using System.Collections;
using System.Diagnostics;
namespace System
{
enum Index
{
case FromFront(int offset);
case FromEnd(int offset);
}
struct IndexRange
{
public Index mStart;
public Index mEnd;
public bool mIsClosed;
public this()
{
this = default;
}
public this(Index start, Index end, bool isClosed=true)
{
mStart = start;
mEnd = end;
mIsClosed = isClosed;
}
public this(int start, Index end, bool isClosed=true)
{
mStart = .FromFront(start);
mEnd = end;
mIsClosed = isClosed;
}
public this(Index start, int end, bool isClosed=true)
{
mStart = start;
mEnd = .FromFront(end);
mIsClosed = isClosed;
}
public this(int start, int end, bool isClosed=true)
{
mStart = .FromFront(start);
mEnd = .FromFront(end);
mIsClosed = isClosed;
}
}
struct Range
{
protected int mStart;
protected int mEnd;
public this()
{
mStart = 0;
mEnd = 0;
}
public this(int start, int end)
{
Debug.Assert(end >= start);
mStart = start;
mEnd = end;
}
}
struct ClosedRange
{
protected int mStart;
protected int mEnd;
public this()
{
mStart = 0;
mEnd = 0;
}
public this(int start, int end)
{
Debug.Assert(end >= start);
mStart = start;
mEnd = end;
}
}
}