Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: lib/src/functions.dart

Issue 2015623003: Fix incorrect identifiers. (Closed) Base URL: git@github.com:dart-lang/collection@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'utils.dart'; 5 import 'utils.dart';
6 6
7 // TODO(nweiz): When sdk#26488 is fixed, use overloads to ensure that if [key] 7 // TODO(nweiz): When sdk#26488 is fixed, use overloads to ensure that if [key]
8 // or [value] isn't passed, `K2`/`V2` defaults to `K1`/`V1`, respectively. 8 // or [value] isn't passed, `K2`/`V2` defaults to `K1`/`V1`, respectively.
9 /// Creates a new map from [map] with new keys and values. 9 /// Creates a new map from [map] with new keys and values.
10 /// 10 ///
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 var/*=S*/ minValue; 69 var/*=S*/ minValue;
70 var/*=T*/ minOrderBy; 70 var/*=T*/ minOrderBy;
71 for (var element in values) { 71 for (var element in values) {
72 var elementOrderBy = orderBy(element); 72 var elementOrderBy = orderBy(element);
73 if (minOrderBy == null || compare(elementOrderBy, minOrderBy) < 0) { 73 if (minOrderBy == null || compare(elementOrderBy, minOrderBy) < 0) {
74 minValue = element; 74 minValue = element;
75 minOrderBy = elementOrderBy; 75 minOrderBy = elementOrderBy;
76 } 76 }
77 } 77 }
78 return min; 78 return minValue;
79 } 79 }
80 80
81 /// Returns the element of [values] for which [orderBy] returns the maximum 81 /// Returns the element of [values] for which [orderBy] returns the maximum
82 /// value. 82 /// value.
83 /// 83 ///
84 /// The values returned by [orderBy] are compared using the [compare] function. 84 /// The values returned by [orderBy] are compared using the [compare] function.
85 /// If [compare] is omitted, values must implement [Comparable<T>] and they are 85 /// If [compare] is omitted, values must implement [Comparable<T>] and they are
86 /// compared using their [Comparable.compareTo]. 86 /// compared using their [Comparable.compareTo].
87 /*=S*/ maxBy/*<S, T>*/(Iterable/*<S>*/ values, /*=T*/ orderBy(/*=S*/ element), 87 /*=S*/ maxBy/*<S, T>*/(Iterable/*<S>*/ values, /*=T*/ orderBy(/*=S*/ element),
88 {int compare(/*=T*/ value1, /*=T*/ value2)}) { 88 {int compare(/*=T*/ value1, /*=T*/ value2)}) {
89 compare ??= defaultCompare/*<T>*/(); 89 compare ??= defaultCompare/*<T>*/();
90 90
91 var/*=S*/ maxValue; 91 var/*=S*/ maxValue;
92 var/*=T*/ maxOrderBy; 92 var/*=T*/ maxOrderBy;
93 for (var element in values) { 93 for (var element in values) {
94 var elementOrderBy = orderBy(element); 94 var elementOrderBy = orderBy(element);
95 if (maxOrderBy == null || compare(elementOrderBy, maxOrderBy) > 0) { 95 if (maxOrderBy == null || compare(elementOrderBy, maxOrderBy) > 0) {
96 maxValue = element; 96 maxValue = element;
97 maxOrderBy = elementOrderBy; 97 maxOrderBy = elementOrderBy;
98 } 98 }
99 } 99 }
100 return max; 100 return maxValue;
101 } 101 }
102 102
103 /// Returns the [transitive closure][] of [graph]. 103 /// Returns the [transitive closure][] of [graph].
104 /// 104 ///
105 /// [transitive closure]: https://en.wikipedia.org/wiki/Transitive_closure 105 /// [transitive closure]: https://en.wikipedia.org/wiki/Transitive_closure
106 /// 106 ///
107 /// This interprets [graph] as a directed graph with a vertex for each key and 107 /// This interprets [graph] as a directed graph with a vertex for each key and
108 /// edges from each key to the values associated with that key. 108 /// edges from each key to the values associated with that key.
109 /// 109 ///
110 /// Assumes that every vertex in the graph has a key to represent it, even if 110 /// Assumes that every vertex in the graph has a key to represent it, even if
(...skipping 19 matching lines...) Expand all
130 if (result[vertex2].contains(vertex1) && 130 if (result[vertex2].contains(vertex1) &&
131 result[vertex1].contains(vertex3)) { 131 result[vertex1].contains(vertex3)) {
132 result[vertex2].add(vertex3); 132 result[vertex2].add(vertex3);
133 } 133 }
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 return result; 138 return result;
139 } 139 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698