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 'package:collection/collection.dart'; 8 : 9 : import 'unmodifiable_wrappers.dart'; 10 : 11 : /// An unmodifiable, empty set which can be constant. 12 : class EmptyUnmodifiableSet<E> extends IterableBase<E> 13 : with UnmodifiableSetMixin<E> 14 : implements UnmodifiableSetView<E> { 15 11 : const EmptyUnmodifiableSet(); 16 : 17 0 : @override 18 0 : Iterator<E> get iterator => Iterable<E>.empty().iterator; 19 0 : @override 20 : int get length => 0; 21 0 : @override 22 0 : EmptyUnmodifiableSet<T> cast<T>() => EmptyUnmodifiableSet<T>(); 23 0 : @override 24 : bool contains(Object? element) => false; 25 0 : @override 26 0 : bool containsAll(Iterable<Object?> other) => other.isEmpty; 27 0 : @override 28 0 : Iterable<E> followedBy(Iterable<E> other) => DelegatingIterable(other); 29 0 : @override 30 : E? lookup(Object? element) => null; 31 0 : @deprecated 32 : @override 33 0 : EmptyUnmodifiableSet<T> retype<T>() => EmptyUnmodifiableSet<T>(); 34 0 : @override 35 : E singleWhere(bool Function(E) test, {E Function()? orElse}) => 36 0 : orElse != null ? orElse() : throw StateError('No element'); 37 0 : @override 38 0 : Iterable<T> whereType<T>() => Iterable.empty(); 39 0 : @override 40 : Set<E> toSet() => {}; 41 0 : @override 42 0 : Set<E> union(Set<E> other) => Set.of(other); 43 0 : @override 44 : Set<E> intersection(Set<Object?> other) => {}; 45 0 : @override 46 : Set<E> difference(Set<Object?> other) => {}; 47 : }