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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/lib/internal/lists.dart

Issue 2698353003: unfork DDC's copy of most SDK libraries (Closed)
Patch Set: revert core_patch Created 3 years, 9 months 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart._internal;
6
7 class Lists {
8 static void copy(List src, int srcStart,
9 List dst, int dstStart, int count) {
10 if (srcStart < dstStart) {
11 for (int i = srcStart + count - 1, j = dstStart + count - 1;
12 i >= srcStart; i--, j--) {
13 dst[j] = src[i];
14 }
15 } else {
16 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) {
17 dst[j] = src[i];
18 }
19 }
20 }
21
22 static bool areEqual(List a, var b) {
23 if (identical(a, b)) return true;
24 if (!(b is List)) return false;
25 int length = a.length;
26 if (length != b.length) return false;
27
28 for (int i = 0; i < length; i++) {
29 if (!identical(a[i], b[i])) return false;
30 }
31 return true;
32 }
33
34 /**
35 * Returns the index in the list [a] of the given [element], starting
36 * the search at index [startIndex] to [endIndex] (exclusive).
37 * Returns -1 if [element] is not found.
38 */
39 static int indexOf(List a,
40 Object element,
41 int startIndex,
42 int endIndex) {
43 if (startIndex >= a.length) {
44 return -1;
45 }
46 if (startIndex < 0) {
47 startIndex = 0;
48 }
49 for (int i = startIndex; i < endIndex; i++) {
50 if (a[i] == element) {
51 return i;
52 }
53 }
54 return -1;
55 }
56
57 /**
58 * Returns the last index in the list [a] of the given [element], starting
59 * the search at index [startIndex] to 0.
60 * Returns -1 if [element] is not found.
61 */
62 static int lastIndexOf(List a, Object element, int startIndex) {
63 if (startIndex < 0) {
64 return -1;
65 }
66 if (startIndex >= a.length) {
67 startIndex = a.length - 1;
68 }
69 for (int i = startIndex; i >= 0; i--) {
70 if (a[i] == element) {
71 return i;
72 }
73 }
74 return -1;
75 }
76
77 static void indicesCheck(List a, int start, int end) {
78 RangeError.checkValidRange(start, end, a.length);
79 }
80
81 static void rangeCheck(List a, int start, int length) {
82 RangeError.checkNotNegative(length);
83 RangeError.checkNotNegative(start);
84 if (start + length > a.length) {
85 String message = "$start + $length must be in the range [0..${a.length}]";
86 throw new RangeError.range(length, 0, a.length - start,
87 "length", message);
88 }
89 }
90 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/lib/internal/list.dart ('k') | pkg/dev_compiler/tool/input_sdk/lib/internal/print.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698