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 'equality.dart'; |
| 8 import 'wrappers.dart'; |
| 9 |
| 10 /// A [Map] whose key equality is determined by an [Equality] object. |
| 11 class EqualitySet<E> extends DelegatingSet<E> { |
| 12 /// Creates a set with equality based on [equality]. |
| 13 EqualitySet(Equality<E> equality) |
| 14 : super(new LinkedHashSet( |
| 15 equals: equality.equals, |
| 16 hashCode: equality.hash, |
| 17 isValidKey: equality.isValidKey)); |
| 18 |
| 19 /// Creates a set with equality based on [equality] that contains all |
| 20 /// elements in [other]. |
| 21 /// |
| 22 /// If [other] has multiple values that are equivalent according to |
| 23 /// [equality], the first one reached during iteration takes precedence. |
| 24 EqualitySet.from(Equality<E> equality, Iterable<E> other) |
| 25 : super(new LinkedHashSet( |
| 26 equals: equality.equals, |
| 27 hashCode: equality.hash, |
| 28 isValidKey: equality.isValidKey)) { |
| 29 addAll(other); |
| 30 } |
| 31 } |
OLD | NEW |