| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "dart:collection"; | 5 import "dart:collection"; |
| 6 | 6 |
| 7 import "comparators.dart"; | 7 import "comparators.dart"; |
| 8 | 8 |
| 9 const int _HASH_MASK = 0x7fffffff; | 9 const int _HASH_MASK = 0x7fffffff; |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (list1 == null || list2 == null) return false; | 157 if (list1 == null || list2 == null) return false; |
| 158 int length = list1.length; | 158 int length = list1.length; |
| 159 if (length != list2.length) return false; | 159 if (length != list2.length) return false; |
| 160 for (int i = 0; i < length; i++) { | 160 for (int i = 0; i < length; i++) { |
| 161 if (!_elementEquality.equals(list1[i], list2[i])) return false; | 161 if (!_elementEquality.equals(list1[i], list2[i])) return false; |
| 162 } | 162 } |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 int hash(List<E> list) { | 166 int hash(List<E> list) { |
| 167 if (elements == null) return null.hashCode; | 167 if (list == null) return null.hashCode; |
| 168 // Jenkins's one-at-a-time hash function. | 168 // Jenkins's one-at-a-time hash function. |
| 169 // This code is almost identical to the one in IterableEquality, except | 169 // This code is almost identical to the one in IterableEquality, except |
| 170 // that it uses indexing instead of iterating to get the elements. | 170 // that it uses indexing instead of iterating to get the elements. |
| 171 int hash = 0; | 171 int hash = 0; |
| 172 for (int i = 0; i < list.length; i++) { | 172 for (int i = 0; i < list.length; i++) { |
| 173 int c = _elementEquality.hash(list[i]); | 173 int c = _elementEquality.hash(list[i]); |
| 174 hash = (hash + c) & _HASH_MASK; | 174 hash = (hash + c) & _HASH_MASK; |
| 175 hash = (hash + (hash << 10)) & _HASH_MASK; | 175 hash = (hash + (hash << 10)) & _HASH_MASK; |
| 176 hash ^= (hash >> 6); | 176 hash ^= (hash >> 6); |
| 177 } | 177 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 class CaseInsensitiveEquality implements Equality<String> { | 456 class CaseInsensitiveEquality implements Equality<String> { |
| 457 const CaseInsensitiveEquality(); | 457 const CaseInsensitiveEquality(); |
| 458 | 458 |
| 459 bool equals(String string1, String string2) => | 459 bool equals(String string1, String string2) => |
| 460 equalsIgnoreAsciiCase(string1, string2); | 460 equalsIgnoreAsciiCase(string1, string2); |
| 461 | 461 |
| 462 int hash(String string) => hashIgnoreAsciiCase(string); | 462 int hash(String string) => hashIgnoreAsciiCase(string); |
| 463 | 463 |
| 464 bool isValidKey(Object object) => object is String; | 464 bool isValidKey(Object object) => object is String; |
| 465 } | 465 } |
| OLD | NEW |