1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 * @fileoverview Quick range computations.
10 tvcm.exportTo('tvcm', function() {
14 this.min_ = undefined;
15 this.max_ = undefined;
19 __proto__: Object.prototype,
23 this.min_ = undefined;
24 this.max_ = undefined;
31 addRange: function(range) {
34 this.addValue(range.min);
35 this.addValue(range.max);
38 addValue: function(value) {
42 this.isEmpty_ = false;
45 this.max_ = Math.max(this.max_, value);
46 this.min_ = Math.min(this.min_, value);
64 return this.max_ - this.min_;
68 return (this.min_ + this.max_) * 0.5;
71 equals: function(that) {
72 if (this.isEmpty && that.isEmpty)
74 if (this.isEmpty != that.isEmpty)
76 return this.min === that.min &&
77 this.max === that.max;
81 Range.compareByMinTimes = function(a, b) {
82 if (!a.isEmpty && !b.isEmpty)
83 return a.min_ - b.min_;
85 if (a.isEmpty && !b.isEmpty)
88 if (!a.isEmpty && b.isEmpty)