| OLD | NEW |
| 1 library java.core; | 1 library java.core; |
| 2 | 2 |
| 3 import "dart:math" as math; | 3 import "dart:math" as math; |
| 4 | 4 |
| 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); | 5 final Stopwatch nanoTimeStopwatch = new Stopwatch(); |
| 6 | 6 |
| 7 const int LONG_MAX_VALUE = 0x7fffffffffffffff; | 7 const int LONG_MAX_VALUE = 0x7fffffffffffffff; |
| 8 | 8 |
| 9 class JavaSystem { | 9 class JavaSystem { |
| 10 static int currentTimeMillis() { | 10 static int currentTimeMillis() { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 | 355 |
| 356 class MissingFormatArgumentException implements Exception { | 356 class MissingFormatArgumentException implements Exception { |
| 357 final String s; | 357 final String s; |
| 358 | 358 |
| 359 String toString() => "MissingFormatArgumentException: $s"; | 359 String toString() => "MissingFormatArgumentException: $s"; |
| 360 | 360 |
| 361 MissingFormatArgumentException(this.s); | 361 MissingFormatArgumentException(this.s); |
| 362 } | 362 } |
| 363 | 363 |
| 364 class JavaIterator<E> { | |
| 365 Iterable<E> _iterable; | |
| 366 List<E> _elements = new List<E>(); | |
| 367 int _coPos = 0; | |
| 368 int _elPos = 0; | |
| 369 E _current = null; | |
| 370 JavaIterator(this._iterable) { | |
| 371 Iterator iterator = _iterable.iterator; | |
| 372 while (iterator.moveNext()) { | |
| 373 _elements.add(iterator.current); | |
| 374 } | |
| 375 } | |
| 376 | |
| 377 bool get hasNext { | |
| 378 return _elPos < _elements.length; | |
| 379 } | |
| 380 | |
| 381 E next() { | |
| 382 _current = _elements[_elPos]; | |
| 383 _coPos++; | |
| 384 _elPos++; | |
| 385 return _current; | |
| 386 } | |
| 387 | |
| 388 void remove() { | |
| 389 if (_iterable is List) { | |
| 390 _coPos--; | |
| 391 (_iterable as List).remove(_coPos); | |
| 392 } else if (_iterable is Set) { | |
| 393 (_iterable as Set).remove(_current); | |
| 394 } else { | |
| 395 throw new StateError("Unsupported iterable ${_iterable.runtimeType}"); | |
| 396 } | |
| 397 } | |
| 398 } | |
| 399 | |
| 400 class MapEntry<K, V> { | |
| 401 final Map<K, V> _map; | |
| 402 final K _key; | |
| 403 V _value; | |
| 404 MapEntry(this._map, this._key, this._value); | |
| 405 K getKey() => _key; | |
| 406 V getValue() => _value; | |
| 407 V setValue(V v) { | |
| 408 V prevValue = _value; | |
| 409 _value = v; | |
| 410 _map[_key] = v; | |
| 411 return prevValue; | |
| 412 } | |
| 413 } | |
| 414 | |
| 415 Iterable<MapEntry> getMapEntrySet(Map m) { | |
| 416 List<MapEntry> result = []; | |
| 417 m.forEach((k, v) { | |
| 418 result.add(new MapEntry(m, k, v)); | |
| 419 }); | |
| 420 return result; | |
| 421 } | |
| 422 | |
| 423 javaListSet(List list, int index, newValue) { | 364 javaListSet(List list, int index, newValue) { |
| 424 var oldValue = list[index]; | 365 var oldValue = list[index]; |
| 425 list[index] = newValue; | 366 list[index] = newValue; |
| 426 return oldValue; | 367 return oldValue; |
| 427 } | 368 } |
| 428 | 369 |
| 429 bool javaCollectionContainsAll(Iterable list, Iterable c) { | 370 bool javaCollectionContainsAll(Iterable list, Iterable c) { |
| 430 return c.fold(true, (bool prev, e) => prev && list.contains(e)); | 371 return c.fold(true, (bool prev, e) => prev && list.contains(e)); |
| 431 } | 372 } |
| 432 | 373 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?' | 457 * format('{0} are you {1}ing?', ['What', 'read']) = 'What are you reading?' |
| 517 */ | 458 */ |
| 518 String formatList(String pattern, List args) { | 459 String formatList(String pattern, List args) { |
| 519 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { | 460 return pattern.replaceAllMapped(new RegExp(r'\{(\d+)\}'), (match) { |
| 520 String indexStr = match.group(1); | 461 String indexStr = match.group(1); |
| 521 int index = int.parse(indexStr); | 462 int index = int.parse(indexStr); |
| 522 var arg = args[index]; | 463 var arg = args[index]; |
| 523 return arg != null ? arg.toString() : null; | 464 return arg != null ? arg.toString() : null; |
| 524 }); | 465 }); |
| 525 } | 466 } |
| OLD | NEW |