@@ -2,18 +2,15 @@ import 'dart:collection';
22
33import 'package:ordered_set/comparing_ordered_set.dart' ;
44import 'package:ordered_set/mapping_ordered_set.dart' ;
5- import 'package:ordered_set/queryable_ordered_set .dart' ;
5+ import 'package:ordered_set/read_only_ordered_set .dart' ;
66
77/// A simple interface of an ordered set for Dart.
88///
99/// It accepts some way of comparing items for their priority. Unlike
1010/// [SplayTreeSet] , it allows for several different elements with the same
1111/// priority to be added. It also implements [Iterable] , so you can iterate it
1212/// in O(n).
13- abstract class OrderedSet <E > extends IterableMixin <E > {
14- /// The tree's elements in reversed order; should be cached when possible.
15- Iterable <E > reversed ();
16-
13+ abstract class OrderedSet <E > extends ReadOnlyOrderedSet <E > {
1714 /// Adds the element [e] to this, and returns whether the element was
1815 /// added or not. If the element already exists in the collection, it isn't
1916 /// added.
@@ -86,43 +83,40 @@ abstract class OrderedSet<E> extends IterableMixin<E> {
8683 ///
8784 /// This implementation will not store component priorities, so it is
8885 /// susceptible to race conditions if priorities are changed while iterating.
89- static ComparingOrderedSet <E > comparing <E >([
86+ static ComparingOrderedSet <E > comparing <E >({
9087 int Function (E a, E b)? compare,
91- ]) {
92- return ComparingOrderedSet <E >(compare);
88+ bool strictMode = true ,
89+ }) {
90+ return ComparingOrderedSet <E >(compare: compare, strictMode: strictMode);
9391 }
9492
9593 /// Creates an instance of [OrderedSet] using the [MappingOrderedSet]
9694 /// implementation and the provided [mappingFunction] .
9795 static MappingOrderedSet <K , E > mapping <K extends Comparable <K >, E >(
98- K Function (E a) mappingFunction,
99- ) {
100- return MappingOrderedSet (mappingFunction);
96+ K Function (E a) mappingFunction, {
97+ bool strictMode = true ,
98+ }) {
99+ return MappingOrderedSet (mappingFunction, strictMode: strictMode);
101100 }
102101
103102 /// Creates an instance of [OrderedSet] for items that are already
104103 /// [Comparable] using the [MappingOrderedSet] implementation.
105104 /// Use this for classes that implement [Comparable] of a different class.
106105 /// Equivalent to `mapping<K, E>((a) => a)` .
107106 static MappingOrderedSet <K , E >
108- comparable <K extends Comparable <K >, E extends K >() {
109- return mapping <K , E >((a) => a);
107+ comparable <K extends Comparable <K >, E extends K >({
108+ bool strictMode = true ,
109+ }) {
110+ return mapping <K , E >((a) => a, strictMode: strictMode);
110111 }
111112
112113 /// Creates an instance of [OrderedSet] for items that are already
113114 /// [Comparable] of themselves, using the [MappingOrderedSet] implementation.
114115 /// Use this for classes that implement [Comparable] of themselves.
115116 /// Equivalent to `mapping<K, K>((a) => a)` .
116- static MappingOrderedSet <E , E > simple <E extends Comparable <E >>() {
117- return comparable <E , E >();
118- }
119-
120- /// Creates an instance of [OrderedSet] using the [QueryableOrderedSet]
121- /// by wrapping the provided [backingSet] .
122- static QueryableOrderedSet <E > queryable <E >(
123- OrderedSet <E > backingSet, {
117+ static MappingOrderedSet <E , E > simple <E extends Comparable <E >>({
124118 bool strictMode = true ,
125119 }) {
126- return QueryableOrderedSet < E >(backingSet, strictMode: strictMode);
120+ return comparable < E , E >( strictMode: strictMode);
127121 }
128122}
0 commit comments