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

Deprecate transitiveClosure #336

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
generic.
- 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