| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 for (int remaining = _extra, i = 0; remaining > 0 && i < CAPACITY; i++) { | 150 for (int remaining = _extra, i = 0; remaining > 0 && i < CAPACITY; i++) { |
| 151 var candidate = _contents[i]; | 151 var candidate = _contents[i]; |
| 152 if (_MARKER == candidate) continue; | 152 if (_MARKER == candidate) continue; |
| 153 if (candidate == element) return candidate; | 153 if (candidate == element) return candidate; |
| 154 remaining--; | 154 remaining--; |
| 155 } | 155 } |
| 156 return null; | 156 return null; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool remove(E element) { | 160 bool remove(Object element) { |
| 161 if (_extra == null) { | 161 if (_extra == null) { |
| 162 if (_contents == element) { | 162 if (_contents == element) { |
| 163 _contents = _MARKER; | 163 _contents = _MARKER; |
| 164 return true; | 164 return true; |
| 165 } else { | 165 } else { |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 } else if (_MARKER == _extra) { | 168 } else if (_MARKER == _extra) { |
| 169 return _contents.remove(element); | 169 return _contents.remove(element); |
| 170 } else { | 170 } else { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if (Setlet._MARKER != candidate) { | 303 if (Setlet._MARKER != candidate) { |
| 304 _current = candidate; | 304 _current = candidate; |
| 305 _remaining--; | 305 _remaining--; |
| 306 return true; | 306 return true; |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 _current = null; | 309 _current = null; |
| 310 return false; | 310 return false; |
| 311 } | 311 } |
| 312 } | 312 } |
| OLD | NEW |