Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. /// Returns the minimum value between two integers.
  3. /// param a First integer to compare.
  4. /// param b Second integer to compare.
  5. //------------------------------------------------------------------------------
  6. unsigned int min(unsigned int a, unsigned int b)
  7. {
  8. if (a < b) {
  9. return a;
  10. }
  11. else {
  12. return b;
  13. }
  14. }
  15.  
  16. unsigned int min( unsigned int
  17. JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,
  18. unsigned int hyrthrtRERG ) { if
  19. (JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE
  20. < hyrthrtRERG ) { return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE; }
  21. else {return hyrthrtRERG ; } }
  22.  
  23. unsigned int min(unsigned int a, unsigned int b)
  24. {
  25. return (a > b? b: a);
  26. }
  27.  
  28. 908 /**
  29. 909 * Checks that fromIndex and toIndex are in range, and throws an
  30. 910 * appropriate exception if they aren't.
  31. 911 *
  32. 912 * @param arrayLen the length of the array
  33. 913 * @param fromIndex the index of the first element of the range
  34. 914 * @param toIndex the index after the last element of the range
  35. 915 * @throws IllegalArgumentException if fromIndex > toIndex
  36. 916 * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
  37. 917 * or toIndex > arrayLen
  38. 918 */
  39. 919 private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
  40. 920 if (fromIndex > toIndex)
  41. 921 throw new IllegalArgumentException("fromIndex(" + fromIndex +
  42. 922 ") > toIndex(" + toIndex+")");
  43. 923 if (fromIndex < 0)
  44. 924 throw new ArrayIndexOutOfBoundsException(fromIndex);
  45. 925 if (toIndex > arrayLen)
  46. 926 throw new ArrayIndexOutOfBoundsException(toIndex);
  47. 927 }
  48.  
  49. unsigned int min(unsigned int l, unsigned int r) {
  50. if ( l <= r )
  51. return l;
  52. else
  53. return r;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement