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 'union_set.dart'; | |
6 | |
7 /// A controller that exposes a view of the union of a collection of sets. | |
8 /// | |
9 /// This is a convenience class for creating a [UnionSet] whose contents change | |
10 /// over the lifetime of a class. For example: | |
11 /// | |
12 /// ```dart | |
13 /// class Engine { | |
14 /// Set<Test> get activeTests => _activeTestsGroup.set; | |
15 /// final _activeTestsGroup = new UnionSetController<Test>(); | |
16 /// | |
17 /// void addSuite(Suite suite) { | |
18 /// _activeTestsGroup.add(suite.tests); | |
19 /// _runSuite(suite); | |
20 /// _activeTestsGroup.remove(suite.tests); | |
21 /// } | |
22 /// } | |
23 /// ``` | |
24 class UnionSetController<E> { | |
25 /// The [UnionSet] that provides a view of the union of sets in [this]. | |
26 UnionSet<E> get set => _set; | |
27 UnionSet<E> _set; | |
28 | |
29 /// The sets whose union is exposed through [set]. | |
30 final _sets = new Set<Set<E>>(); | |
31 | |
32 /// Creates a set of sets that provides a view of the union of those sets. | |
33 /// | |
34 /// If [disjoint] is `true`, this assumes that all component sets are | |
35 /// disjoint—that is, that they contain no elements in common. This makes | |
floitsch
2016/04/27 10:56:52
Please don't use non-ascii characters.
Commonmark
nweiz
2016/04/27 20:47:40
See my other comment. This rule isn't part of the
floitsch
2016/05/09 13:19:18
Forgot to answer that one: having non-Ascii tokens
| |
36 /// many operations including [length] more efficient. | |
37 UnionSetController({bool disjoint: false}) { | |
38 _set = new UnionSet<E>(_sets, disjoint: disjoint); | |
39 } | |
40 | |
41 /// Adds the contents of [component] to [set]. | |
42 /// | |
43 /// If the contents of [component] change over time, [set] will change | |
44 /// accordingly. | |
45 void add(Set<E> component) { | |
46 _sets.add(component); | |
47 } | |
48 | |
49 /// Removes the contents of [component] to [set]. | |
50 /// | |
51 /// If another set in [this] has overlapping elements with [component], those | |
52 /// elements will remain in [set]. | |
53 bool remove(Set<E> component) => _sets.remove(component); | |
54 } | |
OLD | NEW |