Index: lib/src/set_group.dart |
diff --git a/lib/src/set_group.dart b/lib/src/set_group.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bb4c027bb95740d8d538b7542efa5aa856e00c3f |
--- /dev/null |
+++ b/lib/src/set_group.dart |
@@ -0,0 +1,34 @@ |
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+import 'group_set.dart'; |
+import 'wrappers.dart'; |
+ |
+/// A set of sets that provides [set], a view of the union of those sets. |
+/// |
+/// This is a convenience class for creating a [GroupSet] whose contents change |
+/// over the lifetime of a class. For example: |
+/// |
+/// ```dart |
+/// class Foo { |
+/// Set<String> get contents => _contentsGroup.set; |
+/// final _contentsGroup = new SetGroup<String>(); |
+/// |
+/// // ... |
+/// } |
+/// ``` |
+class SetGroup<E> extends DelegatingSet<Set<E>> { |
+ /// The [GroupSet] that provides a view of the union of sets in [this]. |
+ GroupSet<E> get set => _set; |
+ GroupSet<E> _set; |
+ |
+ /// Creates a set of sets that provides a view of the union of those sets. |
+ /// |
+ /// If [disjoint] is `true`, this assumes that all component sets are |
+ /// disjoint—that is, that they contain no elements in common. This makes |
+ /// many operations including [length] more efficient. |
+ SetGroup({bool disjoint: false}) : super(new Set<Set<E>>()) { |
+ _set = new GroupSet<E>(this, disjoint: disjoint); |
+ } |
+} |