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 '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 throw new UnsupportedError("Cannot modify an unmodifiable Set"); |
| 16 } |
| 17 |
| 18 Iterator<E> get iterator => new Iterable<E>.empty().iterator; |
| 19 int get length => 0; |
| 20 |
| 21 const EmptyUnmodifiableSet(); |
| 22 |
| 23 bool contains(Object element) => false; |
| 24 bool containsAll(Iterable<Object> other) => other.isEmpty; |
| 25 E lookup(Object element) => null; |
| 26 Set<E> toSet() => new Set(); |
| 27 Set<E> union(Set<E> other) => new Set.from(other); |
| 28 Set<E> intersection(Set<Object> other) => new Set(); |
| 29 Set<E> difference(Set<Object> other) => new Set(); |
| 30 |
| 31 bool add(E value) => _throw(); |
| 32 void addAll(Iterable<E> elements) => _throw(); |
| 33 void clear() => _throw(); |
| 34 bool remove(Object element) => _throw(); |
| 35 void removeAll(Iterable<Object> elements) => _throw(); |
| 36 void removeWhere(bool test(E element)) => _throw(); |
| 37 void retainWhere(bool test(E element)) => _throw(); |
| 38 void retainAll(Iterable<Object> elements) => _throw(); |
| 39 } |
OLD | NEW |