Mercurial > projects > orange
comparison orange/util/collection/Array.d @ 9:99c52d46822a
Serialization works now with D2, deserialization still doesn't work
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sat, 24 Jul 2010 18:58:18 +0200 |
parents | 11a31bd929f9 |
children | fc315d786f24 |
comparison
equal
deleted
inserted
replaced
8:613a0bb20207 | 9:99c52d46822a |
---|---|
356 * | 356 * |
357 * Throws: AssertException if the length of the array is 0 | 357 * Throws: AssertException if the length of the array is 0 |
358 * Throws: AssertException if the return value is less than -1 or | 358 * Throws: AssertException if the return value is less than -1 or |
359 * greater than the length of the array - 1. | 359 * greater than the length of the array - 1. |
360 */ | 360 */ |
361 U lastIndexOf (T, U = size_t) (T[] arr, T element) | 361 version (Tango) |
362 in | 362 { |
363 { | 363 U lastIndexOf (T, U = size_t) (in T[] arr, T element) |
364 assert(arr.length > 0, "mambo.collection.Array.lastIndexOf: The length of the array was 0"); | 364 in |
365 } | 365 { |
366 body | 366 assert(arr.length > 0, "mambo.collection.Array.lastIndexOf: The length of the array was 0"); |
367 { | 367 } |
368 version (Tango) | 368 body |
369 { | 369 { |
370 U index = tango.text.Util.locatePrior(arr, element); | 370 U index = tango.text.Util.locatePrior(arr, element); |
371 | 371 |
372 if (index == arr.length) | 372 if (index == arr.length) |
373 return U.max; | 373 return U.max; |
374 | 374 |
375 return index; | 375 return index; |
376 } | 376 } |
377 | 377 } |
378 else | 378 |
379 { | 379 else |
380 foreach_reverse (i, e ; arr) | 380 { |
381 U lastIndexOf (T, U = size_t) (in T[] arr, dchar element) | |
382 in | |
383 { | |
384 assert(arr.length > 0, "mambo.collection.Array.lastIndexOf: The length of the array was 0"); | |
385 } | |
386 body | |
387 { | |
388 foreach_reverse (i, dchar e ; arr) | |
381 if (e is element) | 389 if (e is element) |
382 return i; | 390 return i; |
383 | 391 |
384 return U.max; | 392 return U.max; |
385 } | 393 } |