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

Unified Diff: charted/lib/core/utils/lists.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « charted/lib/core/utils/disposer.dart ('k') | charted/lib/core/utils/math.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: charted/lib/core/utils/lists.dart
diff --git a/charted/lib/core/utils/lists.dart b/charted/lib/core/utils/lists.dart
deleted file mode 100644
index d9633f939dc568ade75a98d5b9f2f1a1cd44e909..0000000000000000000000000000000000000000
--- a/charted/lib/core/utils/lists.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-// Copyright 2014 Google Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd
-//
-
-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);
-
-/// 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);
-
-/// 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);
-
-/// 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) =>
- other is Pair && first == other.first && last == other.last;
-
- int get hashCode => hash2(first, last);
-}
-
-/// Represents a pair of mininum and maximum values in a List.
-class Extent<T> extends Pair<T, T> {
- final T min;
- final T max;
-
- factory Extent.items(Iterable<T> items,
- [ Comparator compare = Comparable.compare ]) {
- if (items.length == 0) return new Extent(null, null);
- 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;
- }
- return new Extent(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
-/// and each of the step values between them.
-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;
- }
-
- if (step == 0 || start < stop && step < 0 || start > stop && step > 0) {
- throw new ArgumentError('Invalid range.');
- }
-
- var k = _integerConversionFactor(step.abs()),
- i = -1,
- j;
-
- start *= k;
- stop *= k;
- step *= k;
-
- if (step < 0) {
- while ((j = start + step * ++i) > stop) {
- values.add(integers ? j ~/ k : j / k);
- }
- } else {
- while ((j = start + step * ++i) < stop) {
- 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);
-
- static int _integerConversionFactor(num val) {
- int k = 1;
- while (val * k % 1 > 0) {
- k *= 10;
- }
- return k;
- }
-}
« no previous file with comments | « charted/lib/core/utils/disposer.dart ('k') | charted/lib/core/utils/math.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698