Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Deprecate transitiveClosure (#336)
Browse files Browse the repository at this point in the history
The algorithm is implemented with a more flexible signature in
`package:graphs`.
See dart-lang/tools#104

Use an `ignore_for_file` rather than comment each usage of the
deprecated APIs.
  • Loading branch information
natebosch authored Jun 7, 2024
1 parent 141d83a commit 9e441f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- `CanonicalizedMap`: added constructor `fromEntries`.
- Require Dart `^3.1.0`
- Mark "mixin" classes as `mixin`.
- Deprecate `transitiveClosure`. Consider using `package:graphs`.

## 1.18.0

Expand Down
1 change: 1 addition & 0 deletions lib/src/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ S? maxBy<S, T>(Iterable<S> values, T Function(S) orderBy,
/// that vertex has no outgoing edges. This isn't checked, but if it's not
/// satisfied, the function may crash or provide unexpected output. For example,
/// `{"a": ["b"]}` is not valid, but `{"a": ["b"], "b": []}` is.
@Deprecated('This method will be removed. Consider using package:graphs.')
Map<T, Set<T>> transitiveClosure<T>(Map<T, Iterable<T>> graph) {
// This uses [Warshall's algorithm][], modified not to add a vertex from each
// node to itself.
Expand Down
7 changes: 2 additions & 5 deletions test/functions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: deprecated_member_use_from_same_package

import 'package:collection/collection.dart';
import 'package:test/test.dart';

void main() {
group('mapMap()', () {
test('with an empty map returns an empty map', () {
expect(
// ignore: deprecated_member_use_from_same_package
mapMap({},
key: expectAsync2((_, __) {}, count: 0),
value: expectAsync2((_, __) {}, count: 0)),
Expand All @@ -18,7 +19,6 @@ void main() {

test('with no callbacks, returns a copy of the map', () {
var map = {'foo': 1, 'bar': 2};
// ignore: deprecated_member_use_from_same_package
var result = mapMap<String, int, String, int>(map);
expect(result, equals({'foo': 1, 'bar': 2}));

Expand All @@ -29,23 +29,20 @@ void main() {

test("maps the map's keys", () {
expect(
// ignore: deprecated_member_use_from_same_package
mapMap<String, int, dynamic, int>({'foo': 1, 'bar': 2},
key: (dynamic key, dynamic value) => key[value]),
equals({'o': 1, 'r': 2}));
});

test("maps the map's values", () {
expect(
// ignore: deprecated_member_use_from_same_package
mapMap<String, int, String, dynamic>({'foo': 1, 'bar': 2},
value: (dynamic key, dynamic value) => key[value]),
equals({'foo': 'o', 'bar': 'r'}));
});

test("maps both the map's keys and values", () {
expect(
// ignore: deprecated_member_use_from_same_package
mapMap({'foo': 1, 'bar': 2},
key: (dynamic key, dynamic value) => '$key$value',
value: (dynamic key, dynamic value) => key[value]),
Expand Down

0 comments on commit 9e441f1

Please sign in to comment.