File size: 1,218 Bytes
d883ffe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | using System;
namespace UnityEngine.Rendering.Universal
{
struct InclusiveRange
{
public short start;
public short end;
public InclusiveRange(short startEnd)
{
this.start = startEnd;
this.end = startEnd;
}
public InclusiveRange(short start, short end)
{
this.start = start;
this.end = end;
}
public void Expand(short index)
{
start = Math.Min(start, index);
end = Math.Max(end, index);
}
public void Clamp(short min, short max)
{
start = Math.Max(min, start);
end = Math.Min(max, end);
}
public bool isEmpty => end < start;
public bool Contains(short index)
{
return index >= start && index <= end;
}
public static InclusiveRange Merge(InclusiveRange a, InclusiveRange b) => new(Math.Min(a.start, b.start), Math.Max(a.end, b.end));
public static InclusiveRange empty => new InclusiveRange(short.MaxValue, short.MinValue);
public override string ToString()
{
return $"[{start}, {end}]";
}
}
}
|