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

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 Iterable<E> implements List<E> {
floitsch 2013/04/11 15:17:50 I'm guessing that the ListWrapper extends Collecti
Anders Johnsen 2013/04/12 09:31:14 Done.
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) { 283 void addLast(E value) {
floitsch 2013/04/11 15:17:50 Can be removed.
Anders Johnsen 2013/04/12 09:31:14 Done.
284 elements.add(value); 284 elements.add(value);
285 } 285 }
286 286
287 void addAll(Iterable<E> iterable) { 287 void addAll(Iterable<E> iterable) {
288 elements.addAll(iterable); 288 elements.addAll(iterable);
289 } 289 }
290 290
291 void sort([int compare(E a, E b)]) { 291 void sort([int compare(E a, E b)]) {
292 elements.sort(compare); 292 elements.sort(compare);
293 } 293 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 void insertRange(int start, int length, [E fill]) { 337 void insertRange(int start, int length, [E fill]) {
338 elements.insertRange(start, length, fill); 338 elements.insertRange(start, length, fill);
339 } 339 }
340 340
341 Map<int, E> asMap() { 341 Map<int, E> asMap() {
342 return elements.asMap(); 342 return elements.asMap();
343 } 343 }
344 } 344 }
345 345
346 class JavaIterator<E> { 346 class JavaIterator<E> {
347 Collection<E> _collection; 347 Iterable<E> _iterable;
348 List<E> _elements = new List<E>(); 348 List<E> _elements = new List<E>();
349 int _coPos = 0; 349 int _coPos = 0;
350 int _elPos = 0; 350 int _elPos = 0;
351 E _current = null; 351 E _current = null;
352 JavaIterator(this._collection) { 352 JavaIterator(this._iterable) {
353 Iterator iterator = _collection.iterator; 353 Iterator iterator = _iterable.iterator;
354 while (iterator.moveNext()) { 354 while (iterator.moveNext()) {
355 _elements.add(iterator.current); 355 _elements.add(iterator.current);
356 } 356 }
357 } 357 }
358 358
359 bool get hasNext { 359 bool get hasNext {
360 return _elPos < _elements.length; 360 return _elPos < _elements.length;
361 } 361 }
362 362
363 E next() { 363 E next() {
364 _current = _elements[_elPos]; 364 _current = _elements[_elPos];
365 _coPos++; 365 _coPos++;
366 _elPos++; 366 _elPos++;
367 return _current; 367 return _current;
368 } 368 }
369 369
370 void remove() { 370 void remove() {
371 if (_collection is List) { 371 if (_iterable is List) {
372 _coPos--; 372 _coPos--;
373 (_collection as List).remove(_coPos); 373 (_iterable as List).remove(_coPos);
374 } else if (_collection is Set) { 374 } else if (_iterable is Set) {
375 _collection.remove(_current); 375 _iterable.remove(_current);
376 } else { 376 } else {
377 throw new StateError("Unsupported collection ${_collection.runtimeType}"); 377 throw new StateError("Unsupported iterable ${_iterable.runtimeType}");
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 class MapEntry<K, V> { 382 class MapEntry<K, V> {
383 K _key; 383 K _key;
384 V _value; 384 V _value;
385 MapEntry(this._key, this._value); 385 MapEntry(this._key, this._value);
386 K getKey() => _key; 386 K getKey() => _key;
387 V getValue() => _value; 387 V getValue() => _value;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 } else if (sb.length > newLength) { 438 } else if (sb.length > newLength) {
439 var s = sb.toString().substring(0, newLength); 439 var s = sb.toString().substring(0, newLength);
440 sb = new StringBuffer(s); 440 sb = new StringBuffer(s);
441 } 441 }
442 } 442 }
443 void clear() { 443 void clear() {
444 sb = new StringBuffer(); 444 sb = new StringBuffer();
445 } 445 }
446 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698