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

Side by Side Diff: frog/lib/arrays.dart

Issue 10548047: Remove frog from the repository. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move test and update apidoc.gyp. Created 8 years, 6 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
« no previous file with comments | « frog/lang.dart ('k') | frog/lib/corelib.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class Arrays {
6
7 static void copy(List<Object> src, int srcStart,
8 List<Object> dst, int dstStart, int count) {
9 if (srcStart === null) srcStart = 0;
10 if (dstStart === null) dstStart = 0;
11
12 if (srcStart < dstStart) {
13 for (int i = srcStart + count - 1, j = dstStart + count - 1;
14 i >= srcStart; i--, j--) {
15 dst[j] = src[i];
16 }
17 } else {
18 for (int i = srcStart, j = dstStart; i < srcStart + count; i++, j++) {
19 dst[j] = src[i];
20 }
21 }
22 }
23
24 /**
25 * Returns the index in the array [a] of the given [element], starting
26 * the search at index [startIndex] to [endIndex] (exclusive).
27 * Returns -1 if [element] is not found.
28 */
29 static int indexOf(List a,
30 Object element,
31 int startIndex,
32 int endIndex) {
33 if (startIndex >= a.length) {
34 return -1;
35 }
36 if (startIndex < 0) {
37 startIndex = 0;
38 }
39 for (int i = startIndex; i < endIndex; i++) {
40 if (a[i] == element) {
41 return i;
42 }
43 }
44 return -1;
45 }
46
47 /**
48 * Returns the last index in the array [a] of the given [element], starting
49 * the search at index [startIndex] to 0.
50 * Returns -1 if [element] is not found.
51 */
52 static int lastIndexOf(List a, Object element, int startIndex) {
53 if (startIndex < 0) {
54 return -1;
55 }
56 if (startIndex >= a.length) {
57 startIndex = a.length - 1;
58 }
59 for (int i = startIndex; i >= 0; i--) {
60 if (a[i] == element) {
61 return i;
62 }
63 }
64 return -1;
65 }
66 }
OLDNEW
« no previous file with comments | « frog/lang.dart ('k') | frog/lib/corelib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698