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

Side by Side Diff: editor/util/plugins/com.google.dart.java2dart/resources/java_core.dart

Issue 14173003: Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
1 library java.core; 1 library java.core;
2 2
3 import "dart:math" as math; 3 import "dart:math" as math;
4 import "dart:uri"; 4 import "dart:uri";
5 5
6 class JavaSystem { 6 class JavaSystem {
7 static int currentTimeMillis() { 7 static int currentTimeMillis() {
8 return (new DateTime.now()).millisecondsSinceEpoch; 8 return (new DateTime.now()).millisecondsSinceEpoch;
9 } 9 }
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 250 }
251 251
252 class URISyntaxException implements Exception { 252 class URISyntaxException implements Exception {
253 String toString() => "URISyntaxException"; 253 String toString() => "URISyntaxException";
254 } 254 }
255 255
256 class IOException implements Exception { 256 class IOException implements Exception {
257 String toString() => "IOException"; 257 String toString() => "IOException";
258 } 258 }
259 259
260 class ListWrapper<E> extends Collection<E> implements List<E> { 260 class ListWrapper<E> extends ListBase<E> implements List<E> {
261 List<E> elements = new List<E>(); 261 List<E> elements = new List<E>();
262 262
263 Iterator<E> get iterator { 263 Iterator<E> get iterator {
264 return elements.iterator; 264 return elements.iterator;
265 } 265 }
266 266
267 E operator [](int index) { 267 E operator [](int index) {
268 return elements[index]; 268 return elements[index];
269 } 269 }
270 270
271 void operator []=(int index, E value) { 271 void operator []=(int index, E value) {
272 elements[index] = value; 272 elements[index] = value;
273 } 273 }
274 274
275 void set length(int newLength) { 275 void set length(int newLength) {
276 elements.length = newLength; 276 elements.length = newLength;
277 } 277 }
278 278
279 void add(E value) { 279 void add(E value) {
280 elements.add(value); 280 elements.add(value);
281 } 281 }
282 282
283 void addLast(E value) {
284 elements.add(value);
285 }
286
287 void addAll(Iterable<E> iterable) { 283 void addAll(Iterable<E> iterable) {
288 elements.addAll(iterable); 284 elements.addAll(iterable);
289 } 285 }
290 286
291 void sort([int compare(E a, E b)]) { 287 void sort([int compare(E a, E b)]) {
292 elements.sort(compare); 288 elements.sort(compare);
293 } 289 }
294 290
295 int indexOf(E element, [int start = 0]) { 291 int indexOf(E element, [int start = 0]) {
296 return elements.indexOf(element, start); 292 return elements.indexOf(element, start);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 void insertRange(int start, int length, [E fill]) { 333 void insertRange(int start, int length, [E fill]) {
338 elements.insertRange(start, length, fill); 334 elements.insertRange(start, length, fill);
339 } 335 }
340 336
341 Map<int, E> asMap() { 337 Map<int, E> asMap() {
342 return elements.asMap(); 338 return elements.asMap();
343 } 339 }
344 } 340 }
345 341
346 class JavaIterator<E> { 342 class JavaIterator<E> {
347 Collection<E> _collection; 343 Iterable<E> _iterable;
348 List<E> _elements = new List<E>(); 344 List<E> _elements = new List<E>();
349 int _coPos = 0; 345 int _coPos = 0;
350 int _elPos = 0; 346 int _elPos = 0;
351 E _current = null; 347 E _current = null;
352 JavaIterator(this._collection) { 348 JavaIterator(this._iterable) {
353 Iterator iterator = _collection.iterator; 349 Iterator iterator = _iterable.iterator;
354 while (iterator.moveNext()) { 350 while (iterator.moveNext()) {
355 _elements.add(iterator.current); 351 _elements.add(iterator.current);
356 } 352 }
357 } 353 }
358 354
359 bool get hasNext { 355 bool get hasNext {
360 return _elPos < _elements.length; 356 return _elPos < _elements.length;
361 } 357 }
362 358
363 E next() { 359 E next() {
364 _current = _elements[_elPos]; 360 _current = _elements[_elPos];
365 _coPos++; 361 _coPos++;
366 _elPos++; 362 _elPos++;
367 return _current; 363 return _current;
368 } 364 }
369 365
370 void remove() { 366 void remove() {
371 if (_collection is List) { 367 if (_iterable is List) {
372 _coPos--; 368 _coPos--;
373 (_collection as List).remove(_coPos); 369 (_iterable as List).remove(_coPos);
374 } else if (_collection is Set) { 370 } else if (_iterable is Set) {
375 _collection.remove(_current); 371 _iterable.remove(_current);
376 } else { 372 } else {
377 throw new StateError("Unsupported collection ${_collection.runtimeType}"); 373 throw new StateError("Unsupported iterable ${_iterable.runtimeType}");
378 } 374 }
379 } 375 }
380 } 376 }
381 377
382 class MapEntry<K, V> { 378 class MapEntry<K, V> {
383 K _key; 379 K _key;
384 V _value; 380 V _value;
385 MapEntry(this._key, this._value); 381 MapEntry(this._key, this._value);
386 K getKey() => _key; 382 K getKey() => _key;
387 V getValue() => _value; 383 V getValue() => _value;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 433 }
438 } else if (sb.length > newLength) { 434 } else if (sb.length > newLength) {
439 var s = sb.toString().substring(0, newLength); 435 var s = sb.toString().substring(0, newLength);
440 sb = new StringBuffer(s); 436 sb = new StringBuffer(s);
441 } 437 }
442 } 438 }
443 void clear() { 439 void clear() {
444 sb = new StringBuffer(); 440 sb = new StringBuffer();
445 } 441 }
446 } 442 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698