暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

InclusiveRange.cs 1.2KB

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