OLD | NEW |
1 Contains a number libraries | 1 Contains utility functions and classes in the style of `dart:collection` to make |
2 with utility functions and classes that makes working with collections easier. | 2 working with collections easier. |
3 | 3 |
4 ## Using | |
5 | |
6 The `collection` package can be imported as separate libraries, or | |
7 in totality: | |
8 | |
9 ```dart | |
10 import 'package:collection/algorithms.dart'; | |
11 import 'package:collection/equality.dart'; | |
12 import 'package:collection/iterable_zip.dart'; | |
13 import 'package:collection/priority_queue.dart'; | |
14 import 'package:collection/wrappers.dart'; | |
15 ``` | |
16 | |
17 or | |
18 | |
19 ```dart | |
20 import 'package:collection/collection.dart'; | |
21 ``` | |
22 | |
23 ## Algorithms | 4 ## Algorithms |
24 | 5 |
25 The algorithms library contains functions that operate on lists. | 6 The package contains functions that operate on lists. |
26 | 7 |
27 It contains ways to shuffle a `List`, do binary search on a sorted `List`, and | 8 It contains ways to shuffle a `List`, do binary search on a sorted `List`, and |
28 various sorting algorithms. | 9 various sorting algorithms. |
29 | 10 |
30 | |
31 ## Equality | 11 ## Equality |
32 | 12 |
33 The equality library gives a way to specify equality of elements and | 13 The package provides a way to specify the equality of elements and collections. |
34 collections. | |
35 | 14 |
36 Collections in Dart have no inherent equality. Two sets are not equal, even | 15 Collections in Dart have no inherent equality. Two sets are not equal, even |
37 if they contain exactly the same objects as elements. | 16 if they contain exactly the same objects as elements. |
38 | 17 |
39 The equality library provides a way to say define such an equality. In this | 18 The `Equality` interface provides a way to say define such an equality. In this |
40 case, for example, `const SetEquality(const IdentityEquality())` is an equality | 19 case, for example, `const SetEquality(const IdentityEquality())` is an equality |
41 that considers two sets equal exactly if they contain identical elements. | 20 that considers two sets equal exactly if they contain identical elements. |
42 | 21 |
43 The library provides ways to define equalities on `Iterable`s, `List`s, `Set`s, | 22 Equalities are provided for `Iterable`s, `List`s, `Set`s, and `Map`s, as well as |
44 and `Map`s, as well as combinations of these, such as: | 23 combinations of these, such as: |
45 | 24 |
46 ```dart | 25 ```dart |
47 const MapEquality(const IdentityEquality(), const ListEquality()); | 26 const MapEquality(const IdentityEquality(), const ListEquality()); |
48 ``` | 27 ``` |
49 | 28 |
50 This equality considers maps equal if they have identical keys, and the | 29 This equality considers maps equal if they have identical keys, and the |
51 corresponding values are lists with equal (`operator==`) values. | 30 corresponding values are lists with equal (`operator==`) values. |
52 | 31 |
53 | |
54 ## Iterable Zip | 32 ## Iterable Zip |
55 | 33 |
56 Utilities for "zipping" a list of iterables into an iterable of lists. | 34 Utilities for "zipping" a list of iterables into an iterable of lists. |
57 | 35 |
58 | |
59 ## Priority Queue | 36 ## Priority Queue |
60 | 37 |
61 An interface and implementation of a priority queue. | 38 An interface and implementation of a priority queue. |
62 | 39 |
63 | |
64 ## Wrappers | 40 ## Wrappers |
65 | 41 |
66 The wrappers library contains classes that "wrap" a collection. | 42 The package contains classes that "wrap" a collection. |
67 | 43 |
68 A wrapper class contains an object of the same type, and it forwards all | 44 A wrapper class contains an object of the same type, and it forwards all |
69 methods to the wrapped object. | 45 methods to the wrapped object. |
70 | 46 |
71 Wrapper classes can be used in various ways, for example to restrict the type | 47 Wrapper classes can be used in various ways, for example to restrict the type |
72 of an object to that of a supertype, or to change the behavior of selected | 48 of an object to that of a supertype, or to change the behavior of selected |
73 functions on an existing object. | 49 functions on an existing object. |
74 | 50 |
75 ## Features and bugs | 51 ## Features and bugs |
76 | 52 |
77 Please file feature requests and bugs at the [issue tracker][tracker]. | 53 Please file feature requests and bugs at the [issue tracker][tracker]. |
78 | 54 |
79 [tracker]: https://github.com/dart-lang/collection/issues | 55 [tracker]: https://github.com/dart-lang/collection/issues |
OLD | NEW |