Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'group_set.dart'; | |
| 6 import 'wrappers.dart'; | |
| 7 | |
| 8 /// A set of sets that provides [set], a view of the union of those sets. | |
| 9 /// | |
| 10 /// This is a convenience class for creating a [GroupSet] whose contents change | |
| 11 /// over the lifetime of a class. For example: | |
| 12 /// | |
| 13 /// ```dart | |
| 14 /// class Engine { | |
| 15 /// Set<Test> get activeTests => _activeTestsGroup.set; | |
| 16 /// final _activeTestsGroup = new SetGroup<Test>(); | |
| 17 /// | |
| 18 /// void addSuite(Suite suite) { | |
| 19 /// _activeTestsGroup.add(suite.tests); | |
| 20 /// _runSuite(suite); | |
| 21 /// _activeTestsGroup.remove(suite.tests); | |
| 22 /// } | |
| 23 /// } | |
| 24 /// ``` | |
| 25 class SetGroup<E> extends DelegatingSet<Set<E>> { | |
|
Lasse Reichstein Nielsen
2016/04/23 09:00:47
I do think I'd prefer this class to not be a Set.
floitsch
2016/04/25 16:11:10
Do we even need this class?
I see two ways to avo
nweiz
2016/04/26 21:23:53
Done.
floitsch
2016/04/27 10:56:52
Why?
It's like saying that users expecting an "Ite
Lasse Reichstein Nielsen
2016/04/27 12:17:53
I generally recommend not extending the well-known
floitsch
2016/04/27 12:31:20
I'm not convinced.
A UnionSet supports adding comp
Lasse Reichstein Nielsen
2016/04/27 12:47:00
The GroupSet is just a Set at the interface level.
floitsch
2016/04/27 13:08:47
If that's really necessary, yes. That's how it wor
Lasse Reichstein Nielsen
2016/04/27 14:31:15
I think our difference is mainly in perspective. I
nweiz
2016/04/27 20:47:40
The intent was definitely a view that looks like a
| |
| 26 /// The [GroupSet] that provides a view of the union of sets in [this]. | |
| 27 GroupSet<E> get set => _set; | |
| 28 GroupSet<E> _set; | |
|
floitsch
2016/04/25 16:11:10
This should be final.
nweiz
2016/04/26 21:23:53
Unfortunately it can't be; GroupSet's initializer
floitsch
2016/04/27 10:56:52
True. It was, but isn't anymore.
Looking more at
nweiz
2016/04/27 20:47:40
Allowing a UnionSet to be directly based on an exi
Lasse Reichstein Nielsen
2016/04/27 21:03:30
Allowing a UnionSet to be directly based on an exi
nweiz
2016/05/03 01:05:36
Right now it's the former: a class that exposes a
Lasse Reichstein Nielsen
2016/05/03 08:27:13
Yes, so I'm good too :)
| |
| 29 | |
| 30 /// Creates a set of sets that provides a view of the union of those sets. | |
| 31 /// | |
| 32 /// If [disjoint] is `true`, this assumes that all component sets are | |
| 33 /// disjoint—that is, that they contain no elements in common. This makes | |
| 34 /// many operations including [length] more efficient. | |
| 35 SetGroup({bool disjoint: false}) : super(new Set<Set<E>>()) { | |
| 36 _set = new GroupSet<E>(this, disjoint: disjoint); | |
| 37 } | |
| 38 } | |
| OLD | NEW |