Skip to content

Commit ed14e5e

Browse files
committed
Fix docs
1 parent c210922 commit ed14e5e

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,15 @@ Note that you could instead just create a `MappingOrderedSet` instead:
6767
// ...
6868
```
6969

70-
## Mapping vs Comparing vs Queryable
70+
## Mapping vs Comparing
7171

72-
There are three main implementations of the `OrderedSet` interface:
72+
There are two main implementations of the `OrderedSet` interface:
7373

7474
* `ComparingOrderedSet`: the simplest implementation, takes in a `Comparator` and does not cache
7575
priorities. It uses Dart's `SplayTreeSet` as a backing implementation.
7676
* `MappingOrderedSet`: a slightly more advanced implementation that takes in a mapper function
7777
(maps elements to their priorities) and caches them. It uses Dart's `SplayTreeMap` as a backing
7878
implementation.
79-
* `QueryableOrderedSet`: a simple wrapper over either `OrderedSet` that allows for O(1) type
80-
queries; if you find yourself doing `.whereType<T>()` a lot, you should consider using this.
8179

8280
In order to create an `OrderedSet`, however, you can just use the static methods on the interface
8381
itself:
@@ -90,7 +88,19 @@ itself:
9088
a `MappingOrderedSet` with identity mapping.
9189
* `OrderedSet.simple<E>()`: if `E extends Comparable<E>`, this is an even simpler way of creating
9290
a `MappingOrderedSet` with identity mapping.
93-
* `OrderedSet.queryable<E>(orderedSet)`: wraps the given `OrderedSet` into a `QueryableOrderedSet`.
91+
92+
## Querying
93+
94+
You can [register] a set of queries, i.e., predefined sub-types, whose results,
95+
i.e., subsets of this set, are then cached.
96+
Since the queries have to be type checks, and types are runtime constants, this
97+
can be vastly optimized.
98+
99+
You can then filter by type by using the [query] method (or using [whereType];
100+
which is overridden).
101+
102+
Note that you can change [strictMode] to allow for querying for unregistered
103+
types; if you do so, the registration cost is payed on the first query.
94104

95105
## Contributing
96106

lib/queryable_ordered_set_impl.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@ import 'package:ordered_set/ordered_set.dart';
77
/// results, i.e., subsets of this set, are then cached. Since the queries
88
/// have to be type checks, and types are runtime constants, this can be
99
/// vastly optimized.
10-
///
11-
/// If you find yourself doing a lot of:
12-
///
13-
/// ```dart
14-
/// orderedSet.whereType<Foo>()
15-
/// ```
16-
///
17-
/// On your code, and are concerned you are iterating a very long O(n) list to
18-
/// find a handful of elements, specially if this is done every tick, you
19-
/// can use this class, that pays a small O(number of registers) cost on [add],
20-
/// but lets you find (specific) subsets at O(0).
10+
///
11+
/// You can then filter by type by using the [query] method (or using [whereType];
12+
/// which is overridden).
2113
///
2214
/// Note that you can change [strictMode] to allow for querying for unregistered
2315
/// types; if you do so, the registration cost is payed on the first query.

0 commit comments

Comments
 (0)