Line data Source code
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 'dart:collection';
6 :
7 : import 'unmodifiable_wrappers.dart';
8 :
9 : // Unfortunately, we can't use UnmodifiableSetMixin here, since const classes
10 : // can't use mixins.
11 : /// An unmodifiable, empty set that can have a const constructor.
12 : class EmptyUnmodifiableSet<E> extends IterableBase<E>
13 : implements UnmodifiableSetView<E> {
14 : static T _throw<T>() {
15 0 : throw new UnsupportedError("Cannot modify an unmodifiable Set");
16 : }
17 :
18 0 : Iterator<E> get iterator => new Iterable<E>.empty().iterator;
19 : int get length => 0;
20 :
21 0 : const EmptyUnmodifiableSet();
22 :
23 : bool contains(Object element) => false;
24 0 : bool containsAll(Iterable<Object> other) => other.isEmpty;
25 : E lookup(Object element) => null;
26 0 : Set<E> toSet() => new Set();
27 0 : Set<E> union(Set<E> other) => new Set.from(other);
28 0 : Set<E> intersection(Set<Object> other) => new Set();
29 0 : Set<E> difference(Set<Object> other) => new Set();
30 :
31 0 : bool add(E value) => _throw();
32 0 : void addAll(Iterable<E> elements) => _throw();
33 0 : void clear() => _throw();
34 0 : bool remove(Object element) => _throw();
35 0 : void removeAll(Iterable<Object> elements) => _throw();
36 0 : void removeWhere(bool test(E element)) => _throw();
37 0 : void retainWhere(bool test(E element)) => _throw();
38 0 : void retainAll(Iterable<Object> elements) => _throw();
39 : }
|