OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /** | 5 /** |
6 * Base implementations of [Set]. | 6 * Base implementations of [Set]. |
7 */ | 7 */ |
8 part of dart.collection; | 8 part of dart.collection; |
9 | 9 |
10 /** | 10 /** |
(...skipping 11 matching lines...) Expand all Loading... |
22 * | 22 * |
23 * Implementations of `Set` using this mixin should consider also implementing | 23 * Implementations of `Set` using this mixin should consider also implementing |
24 * `clear` in constant time. The default implementation works by removing every | 24 * `clear` in constant time. The default implementation works by removing every |
25 * element. | 25 * element. |
26 */ | 26 */ |
27 abstract class SetMixin<E> implements Set<E> { | 27 abstract class SetMixin<E> implements Set<E> { |
28 // This class reimplements all of [IterableMixin]. | 28 // This class reimplements all of [IterableMixin]. |
29 // If/when Dart mixins get more powerful, we should just create a single | 29 // If/when Dart mixins get more powerful, we should just create a single |
30 // Mixin class from IterableMixin and the new methods of this class. | 30 // Mixin class from IterableMixin and the new methods of this class. |
31 | 31 |
32 bool add(E element); | 32 bool add(E value); |
33 | 33 |
34 bool contains(Object element); | 34 bool contains(Object element); |
35 | 35 |
36 E lookup(Object element); | 36 E lookup(Object element); |
37 | 37 |
38 bool remove(Object element); | 38 bool remove(Object value); |
39 | 39 |
40 Iterator<E> get iterator; | 40 Iterator<E> get iterator; |
41 | 41 |
42 Set<E> toSet(); | 42 Set<E> toSet(); |
43 | 43 |
44 int get length; | 44 int get length; |
45 | 45 |
46 bool get isEmpty => length == 0; | 46 bool get isEmpty => length == 0; |
47 | 47 |
48 bool get isNotEmpty => length != 0; | 48 bool get isNotEmpty => length != 0; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 abstract class SetBase<E> extends SetMixin<E> { | 301 abstract class SetBase<E> extends SetMixin<E> { |
302 /** | 302 /** |
303 * Convert a `Set` to a string as `{each, element, as, string}`. | 303 * Convert a `Set` to a string as `{each, element, as, string}`. |
304 * | 304 * |
305 * Handles circular references where converting one of the elements | 305 * Handles circular references where converting one of the elements |
306 * to a string ends up converting [set] to a string again. | 306 * to a string ends up converting [set] to a string again. |
307 */ | 307 */ |
308 static String setToString(Set set) => | 308 static String setToString(Set set) => |
309 IterableBase.iterableToFullString(set, '{', '}'); | 309 IterableBase.iterableToFullString(set, '{', '}'); |
310 } | 310 } |
OLD | NEW |