Interval.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace regex
  7. {
  8. struct Interval
  9. {
  10. Field(int) begin;
  11. Field(int) end;
  12. public:
  13. Interval(): begin(0), end(0)
  14. {
  15. }
  16. Interval(int start) : begin(start), end(start)
  17. {
  18. }
  19. Interval(int start, int end) : begin(start), end(end)
  20. {
  21. }
  22. inline int Begin() { return begin; }
  23. inline void Begin(int value) { begin = value; }
  24. inline int End() { return end; }
  25. inline void End(int value) { end = value; }
  26. bool Includes(int value) const;
  27. bool Includes(Interval other) const;
  28. int CompareTo(Interval other);
  29. static int Compare(Interval x, Interval y);
  30. bool Equals(Interval other);
  31. static bool Equals(Interval x, Interval y);
  32. int GetHashCode();
  33. static int GetHashCode(Interval item);
  34. };
  35. }