| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('media', function() { | 5 cr.define('media', function() { |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This class represents a collection of non-intersecting ranges. Ranges | 8 * This class represents a collection of non-intersecting ranges. Ranges |
| 9 * specified by (start, end) can be added and removed at will. It is used to | 9 * specified by (start, end) can be added and removed at will. It is used to |
| 10 * record which sections of a media file have been cached, e.g. the first and | 10 * record which sections of a media file have been cached, e.g. the first and |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 starts.sort(function(a, b) { | 118 starts.sort(function(a, b) { |
| 119 return a - b; | 119 return a - b; |
| 120 }); | 120 }); |
| 121 | 121 |
| 122 var ranges = this.ranges_; | 122 var ranges = this.ranges_; |
| 123 var results = starts.map(function(s) { | 123 var results = starts.map(function(s) { |
| 124 return mapper(s, ranges[s]); | 124 return mapper(s, ranges[s]); |
| 125 }); | 125 }); |
| 126 | 126 |
| 127 return results; | 127 return results; |
| 128 } | 128 }, |
| 129 |
| 130 /** |
| 131 * Finds the maximum value present in any of the contained ranges. |
| 132 * @return {int} The maximum value contained by this DisjointRangeSet. |
| 133 */ |
| 134 max: function() { |
| 135 var max = -Infinity; |
| 136 for (var start in this.ranges_) |
| 137 max = Math.max(max, this.ranges_[start]); |
| 138 return max; |
| 139 }, |
| 129 }; | 140 }; |
| 130 | 141 |
| 131 return { | 142 return { |
| 132 DisjointRangeSet: DisjointRangeSet | 143 DisjointRangeSet: DisjointRangeSet |
| 133 }; | 144 }; |
| 134 }); | 145 }); |
| OLD | NEW |