Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1384)

Side by Side Diff: sdk/lib/collection/arrays.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO(ngeoffray): Rename to Lists. 5 // TODO(ngeoffray): Rename to Lists.
6 class Arrays { 6 class Arrays {
7 static void copy(List src, int srcStart, 7 static void copy(List src, int srcStart,
8 List dst, int dstStart, int count) { 8 List dst, int dstStart, int count) {
9 if (srcStart === null) srcStart = 0; 9 if (srcStart == null) srcStart = 0;
10 if (dstStart === null) dstStart = 0; 10 if (dstStart == null) dstStart = 0;
11 11
12 if (srcStart < dstStart) { 12 if (srcStart < dstStart) {
13 for (int i = srcStart + count - 1, j = dstStart + count - 1; 13 for (int i = srcStart + count - 1, j = dstStart + count - 1;
14 i >= srcStart; i--, j--) { 14 i >= srcStart; i--, j--) {
15 dst[j] = src[i]; 15 dst[j] = src[i];
16 } 16 }
17 } else { 17 } else {
18 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) { 18 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) {
19 dst[j] = src[i]; 19 dst[j] = src[i];
20 } 20 }
21 } 21 }
22 } 22 }
23 23
24 static bool areEqual(List a, Object b) { 24 static bool areEqual(List a, Object b) {
25 if (a === b) return true; 25 if (identical(a, b)) return true;
26 if (!(b is List)) return false; 26 if (!(b is List)) return false;
27 int length = a.length; 27 int length = a.length;
28 if (length != b.length) return false; 28 if (length != b.length) return false;
29 29
30 for (int i = 0; i < length; i++) { 30 for (int i = 0; i < length; i++) {
31 if (a[i] !== b[i]) return false; 31 if (!identical(a[i], b[i])) return false;
32 } 32 }
33 return true; 33 return true;
34 } 34 }
35 35
36 /** 36 /**
37 * Returns the index in the list [a] of the given [element], starting 37 * Returns the index in the list [a] of the given [element], starting
38 * the search at index [startIndex] to [endIndex] (exclusive). 38 * the search at index [startIndex] to [endIndex] (exclusive).
39 * Returns -1 if [element] is not found. 39 * Returns -1 if [element] is not found.
40 */ 40 */
41 static int indexOf(List a, 41 static int indexOf(List a,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (start < 0 ) { 83 if (start < 0 ) {
84 String message = "$start must be greater than or equal to 0"; 84 String message = "$start must be greater than or equal to 0";
85 throw new RangeError(message); 85 throw new RangeError(message);
86 } 86 }
87 if (start + length > a.length) { 87 if (start + length > a.length) {
88 String message = "$start + $length must be in the range [0..${a.length})"; 88 String message = "$start + $length must be in the range [0..${a.length})";
89 throw new RangeError(message); 89 throw new RangeError(message);
90 } 90 }
91 } 91 }
92 } 92 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/types/concrete_types_inferrer.dart ('k') | sdk/lib/collection/splay_tree.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698