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

Side by Side Diff: tool/input_sdk/lib/html/html_common/lists.dart

Issue 1528613004: First cut of mini dart:html. (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Fix build_sdk Created 5 years 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) 2011, 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 html_common;
6
7 class Lists {
8
9 /**
10 * Returns the index in the array [a] of the given [element], starting
11 * the search at index [startIndex] to [endIndex] (exclusive).
12 * Returns -1 if [element] is not found.
13 */
14 static int indexOf(List a,
15 Object element,
16 int startIndex,
17 int endIndex) {
18 if (startIndex >= a.length) {
19 return -1;
20 }
21 if (startIndex < 0) {
22 startIndex = 0;
23 }
24 for (int i = startIndex; i < endIndex; i++) {
25 if (a[i] == element) {
26 return i;
27 }
28 }
29 return -1;
30 }
31
32 /**
33 * Returns the last index in the array [a] of the given [element], starting
34 * the search at index [startIndex] to 0.
35 * Returns -1 if [element] is not found.
36 */
37 static int lastIndexOf(List a, Object element, int startIndex) {
38 if (startIndex < 0) {
39 return -1;
40 }
41 if (startIndex >= a.length) {
42 startIndex = a.length - 1;
43 }
44 for (int i = startIndex; i >= 0; i--) {
45 if (a[i] == element) {
46 return i;
47 }
48 }
49 return -1;
50 }
51
52 /**
53 * Returns a sub list copy of this list, from [start] to
54 * [end] ([end] not inclusive).
55 * Returns an empty list if [length] is 0.
56 * It is an error if indices are not valid for the list, or
57 * if [end] is before [start].
58 */
59 static List getRange(List a, int start, int end, List accumulator) {
60 if (start < 0) throw new RangeError.value(start);
61 if (end < start) throw new RangeError.value(end);
62 if (end > a.length) throw new RangeError.value(end);
63 for (int i = start; i < end; i++) {
64 accumulator.add(a[i]);
65 }
66 return accumulator;
67 }
68 }
69
70 /**
71 * For accessing underlying node lists, for dart:js interop.
72 */
73 abstract class NodeListWrapper {
74 List<Node> get rawList;
75 }
OLDNEW
« no previous file with comments | « tool/input_sdk/lib/html/html_common/html_common_ddc.dart ('k') | tool/input_sdk/lib/html/html_common/metadata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698