Index: packages/charted/lib/core/utils/lists.dart |
diff --git a/packages/charted/lib/core/utils/lists.dart b/packages/charted/lib/core/utils/lists.dart |
index d9633f939dc568ade75a98d5b9f2f1a1cd44e909..3a5b05ca0bd186049b25a0b44f931e5e37e14f14 100644 |
--- a/packages/charted/lib/core/utils/lists.dart |
+++ b/packages/charted/lib/core/utils/lists.dart |
@@ -9,30 +9,30 @@ |
part of charted.core.utils; |
/// Returns a sum of all values in the given list of values |
-num sum(List values) => |
- values == null || values.isEmpty ? |
- 0: values.fold(0.0, (old, next) => old + next); |
+num sum(List values) => values == null || values.isEmpty |
+ ? 0 |
+ : values.fold(0.0, (old, next) => old + next); |
/// Returns the smallest number in the given list of values |
-num min(Iterable values) => |
- values == null || values.isEmpty ? |
- null : values.fold(values.elementAt(0), math.min); |
+num min(Iterable values) => values == null || values.isEmpty |
+ ? null |
+ : values.fold(values.elementAt(0), math.min); |
/// Returns the largest number in the given list of values |
-num max(Iterable values) => |
- values == null || values.isEmpty ? |
- null : values.fold(values.elementAt(0), math.max); |
+num max(Iterable values) => values == null || values.isEmpty |
+ ? null |
+ : values.fold(values.elementAt(0), math.max); |
/// Represents a constant pair of values |
class Pair<T1, T2> { |
final T1 first; |
final T2 last; |
- |
+ |
const Pair(this.first, this.last); |
- |
- bool operator==(other) => |
+ |
+ bool operator ==(other) => |
other is Pair && first == other.first && last == other.last; |
- |
+ |
int get hashCode => hash2(first, last); |
} |
@@ -42,10 +42,9 @@ class Extent<T> extends Pair<T, T> { |
final T max; |
factory Extent.items(Iterable<T> items, |
- [ Comparator compare = Comparable.compare ]) { |
+ [Comparator compare = Comparable.compare]) { |
if (items.length == 0) return new Extent(null, null); |
- var max = items.first, |
- min = items.first; |
+ var max = items.first, min = items.first; |
for (var value in items) { |
if (compare(max, value) < 0) max = value; |
if (compare(min, value) > 0) min = value; |
@@ -53,7 +52,10 @@ class Extent<T> extends Pair<T, T> { |
return new Extent(min, max); |
} |
- const Extent(T min, T max) : min = min, max = max, super(min, max); |
+ const Extent(T min, T max) |
+ : min = min, |
+ max = max, |
+ super(min, max); |
} |
/// Iterable representing a range of values containing the start, stop |
@@ -62,13 +64,13 @@ class Range extends DelegatingList<num> { |
final num start; |
final num stop; |
final num step; |
- |
+ |
factory Range.integers(num start, [num stop, num step = 1]) => |
new Range(start, stop, step, true); |
factory Range(num start, [num stop, num step = 1, bool integers = false]) { |
List<num> values = <num>[]; |
- |
+ |
if (stop == null) { |
stop = start; |
start = 0; |
@@ -78,9 +80,7 @@ class Range extends DelegatingList<num> { |
throw new ArgumentError('Invalid range.'); |
} |
- var k = _integerConversionFactor(step.abs()), |
- i = -1, |
- j; |
+ var k = _integerConversionFactor(step.abs()), i = -1, j; |
start *= k; |
stop *= k; |
@@ -95,10 +95,10 @@ class Range extends DelegatingList<num> { |
values.add(integers ? j ~/ k : j / k); |
} |
} |
- |
+ |
return new Range._internal(start, stop, step, values); |
} |
- |
+ |
Range._internal(this.start, this.stop, this.step, List values) |
: super(values); |