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