| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.util.setlet; | 5 library dart2js.util.setlet; |
| 6 | 6 |
| 7 import 'dart:collection' show IterableBase; | 7 import 'dart:collection' show IterableBase; |
| 8 | 8 |
| 9 class Setlet<E> extends IterableBase<E> implements Set<E> { | 9 class Setlet<E> extends IterableBase<E> implements Set<E> { |
| 10 static const _MARKER = const _SetletMarker(); | 10 static const _MARKER = const _SetletMarker(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 clear() { | 243 clear() { |
| 244 _contents = _MARKER; | 244 _contents = _MARKER; |
| 245 _extra = null; | 245 _extra = null; |
| 246 } | 246 } |
| 247 | 247 |
| 248 Set<E> union(Set<E> other) => new Set<E>.from(this)..addAll(other); | 248 Set<E> union(Set<E> other) => new Set<E>.from(this)..addAll(other); |
| 249 | 249 |
| 250 Setlet<E> intersection(Set<E> other) => | 250 Setlet<E> intersection(Set<E> other) => |
| 251 new Setlet<E>.from(this.where((e) => other.contains(e))); | 251 new Setlet<E>.from(this.where((e) => other.contains(e))); |
| 252 | 252 |
| 253 Setlet<E> difference(Set<E> other) => | 253 Setlet<E> difference(Set<Object> other) => |
| 254 new Setlet<E>.from(this.where((e) => !other.contains(e))); | 254 new Setlet<E>.from(this.where((e) => !other.contains(e))); |
| 255 | 255 |
| 256 Setlet<E> toSet() { | 256 Setlet<E> toSet() { |
| 257 Setlet<E> result = new Setlet<E>(); | 257 Setlet<E> result = new Setlet<E>(); |
| 258 if (_extra == null) { | 258 if (_extra == null) { |
| 259 result._contents = _contents; | 259 result._contents = _contents; |
| 260 } else if (_extra == _MARKER) { | 260 } else if (_extra == _MARKER) { |
| 261 result._extra = _MARKER; | 261 result._extra = _MARKER; |
| 262 result._contents = _contents.toSet(); | 262 result._contents = _contents.toSet(); |
| 263 } else { | 263 } else { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (Setlet._MARKER != candidate) { | 306 if (Setlet._MARKER != candidate) { |
| 307 _current = candidate; | 307 _current = candidate; |
| 308 _remaining--; | 308 _remaining--; |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 _current = null; | 312 _current = null; |
| 313 return false; | 313 return false; |
| 314 } | 314 } |
| 315 } | 315 } |
| OLD | NEW |