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

Side by Side Diff: client/html/src/_Lists.dart

Issue 9207020: Add tests for Element#elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
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 // TODO(jacobr): move into a core library or at least merge with the copy
6 // in client/dom/src
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 }
OLDNEW
« no previous file with comments | « client/html/src/NodeWrappingImplementation.dart ('k') | client/tests/client/html/ElementTests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698