IntComparer.cs 670 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. namespace UnityTest
  3. {
  4. public class IntComparer : ComparerBaseGeneric<int>
  5. {
  6. public enum CompareType
  7. {
  8. Equal,
  9. NotEqual,
  10. Greater,
  11. GreaterOrEqual,
  12. Less,
  13. LessOrEqual
  14. };
  15. public CompareType compareType;
  16. protected override bool Compare (int a, int b)
  17. {
  18. switch (compareType)
  19. {
  20. case CompareType.Equal:
  21. return a == b;
  22. case CompareType.NotEqual:
  23. return a != b;
  24. case CompareType.Greater:
  25. return a > b;
  26. case CompareType.GreaterOrEqual:
  27. return a >= b;
  28. case CompareType.Less:
  29. return a < b;
  30. case CompareType.LessOrEqual:
  31. return a <= b;
  32. }
  33. throw new Exception ();
  34. }
  35. }
  36. }