hash_values.dart 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. class _HashEnd {
  2. const _HashEnd();
  3. }
  4. const _HashEnd _hashEnd = _HashEnd();
  5. class _Jenkins {
  6. static int combine(int hash, Object o) {
  7. assert(o is! Iterable);
  8. hash = 0x1fffffff & (hash + o.hashCode);
  9. hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10));
  10. return hash ^ (hash >> 6);
  11. }
  12. static int finish(int hash) {
  13. hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3));
  14. hash = hash ^ (hash >> 11);
  15. return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
  16. }
  17. }
  18. int hashValues(Object arg01, Object arg02,
  19. [Object arg03 = _hashEnd,
  20. Object arg04 = _hashEnd,
  21. Object arg05 = _hashEnd,
  22. Object arg06 = _hashEnd,
  23. Object arg07 = _hashEnd,
  24. Object arg08 = _hashEnd,
  25. Object arg09 = _hashEnd,
  26. Object arg10 = _hashEnd,
  27. Object arg11 = _hashEnd,
  28. Object arg12 = _hashEnd,
  29. Object arg13 = _hashEnd,
  30. Object arg14 = _hashEnd,
  31. Object arg15 = _hashEnd,
  32. Object arg16 = _hashEnd,
  33. Object arg17 = _hashEnd,
  34. Object arg18 = _hashEnd,
  35. Object arg19 = _hashEnd,
  36. Object arg20 = _hashEnd]) {
  37. int result = 0;
  38. result = _Jenkins.combine(result, arg01);
  39. result = _Jenkins.combine(result, arg02);
  40. if (!identical(arg03, _hashEnd)) {
  41. result = _Jenkins.combine(result, arg03);
  42. if (!identical(arg04, _hashEnd)) {
  43. result = _Jenkins.combine(result, arg04);
  44. if (!identical(arg05, _hashEnd)) {
  45. result = _Jenkins.combine(result, arg05);
  46. if (!identical(arg06, _hashEnd)) {
  47. result = _Jenkins.combine(result, arg06);
  48. if (!identical(arg07, _hashEnd)) {
  49. result = _Jenkins.combine(result, arg07);
  50. if (!identical(arg08, _hashEnd)) {
  51. result = _Jenkins.combine(result, arg08);
  52. if (!identical(arg09, _hashEnd)) {
  53. result = _Jenkins.combine(result, arg09);
  54. if (!identical(arg10, _hashEnd)) {
  55. result = _Jenkins.combine(result, arg10);
  56. if (!identical(arg11, _hashEnd)) {
  57. result = _Jenkins.combine(result, arg11);
  58. if (!identical(arg12, _hashEnd)) {
  59. result = _Jenkins.combine(result, arg12);
  60. if (!identical(arg13, _hashEnd)) {
  61. result = _Jenkins.combine(result, arg13);
  62. if (!identical(arg14, _hashEnd)) {
  63. result = _Jenkins.combine(result, arg14);
  64. if (!identical(arg15, _hashEnd)) {
  65. result = _Jenkins.combine(result, arg15);
  66. if (!identical(arg16, _hashEnd)) {
  67. result = _Jenkins.combine(result, arg16);
  68. if (!identical(arg17, _hashEnd)) {
  69. result = _Jenkins.combine(result, arg17);
  70. if (!identical(arg18, _hashEnd)) {
  71. result = _Jenkins.combine(result, arg18);
  72. if (!identical(arg19, _hashEnd)) {
  73. result = _Jenkins.combine(result, arg19);
  74. if (!identical(arg20, _hashEnd)) {
  75. result = _Jenkins.combine(result, arg20);
  76. // I can see my house from here!
  77. }
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. return _Jenkins.finish(result);
  96. }
  97. int hashList(Iterable<Object> arguments) {
  98. int result = 0;
  99. if (arguments != null) {
  100. for (Object argument in arguments)
  101. result = _Jenkins.combine(result, argument);
  102. }
  103. return _Jenkins.finish(result);
  104. }