/src/mozilla-central/dom/media/Intervals.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef INTERVALS_H |
8 | | #define INTERVALS_H |
9 | | |
10 | | #include <algorithm> |
11 | | #include "mozilla/TypeTraits.h" |
12 | | #include "nsTArray.h" |
13 | | |
14 | | // Specialization for nsTArray CopyChooser. |
15 | | namespace mozilla { |
16 | | namespace media { |
17 | | template<class T> |
18 | | class IntervalSet; |
19 | | } // namespace media |
20 | | } // namespace mozilla |
21 | | |
22 | | template<class E> |
23 | | struct nsTArray_CopyChooser<mozilla::media::IntervalSet<E>> |
24 | | { |
25 | | typedef nsTArray_CopyWithConstructors<mozilla::media::IntervalSet<E>> Type; |
26 | | }; |
27 | | |
28 | | namespace mozilla { |
29 | | namespace media { |
30 | | |
31 | | /* Interval defines an interval between two points. Unlike a traditional |
32 | | interval [A,B] where A <= x <= B, the upper boundary B is exclusive: A <= x < B |
33 | | (e.g [A,B[ or [A,B) depending on where you're living) |
34 | | It provides basic interval arithmetic and fuzzy edges. |
35 | | The type T must provides a default constructor and +, -, <, <= and == |
36 | | operators. |
37 | | */ |
38 | | template<typename T> |
39 | | class Interval |
40 | | { |
41 | | public: |
42 | | typedef Interval<T> SelfType; |
43 | | |
44 | | Interval() |
45 | | : mStart(T()) |
46 | | , mEnd(T()) |
47 | | , mFuzz(T()) |
48 | 0 | { } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval() Unexecuted instantiation: mozilla::media::Interval<int>::Interval() |
49 | | |
50 | | template<typename StartArg, typename EndArg> |
51 | | Interval(StartArg&& aStart, EndArg&& aEnd) |
52 | | : mStart(std::forward<StartArg>(aStart)) |
53 | | , mEnd(std::forward<EndArg>(aEnd)) |
54 | | , mFuzz() |
55 | 0 | { |
56 | 0 | MOZ_ASSERT(aStart <= aEnd); |
57 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&>(mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&) Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit, mozilla::media::TimeUnit>(mozilla::media::TimeUnit&&, mozilla::media::TimeUnit&&) Unexecuted instantiation: mozilla::media::Interval<double>::Interval<double&, double&>(double&, double&) Unexecuted instantiation: mozilla::media::Interval<long>::Interval<int, long>(int&&, long&&) Unexecuted instantiation: mozilla::media::Interval<long>::Interval<int, long&>(int&&, long&) Unexecuted instantiation: mozilla::media::Interval<long>::Interval<long&, long&>(long&, long&) Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit&, mozilla::media::TimeUnit>(mozilla::media::TimeUnit&, mozilla::media::TimeUnit&&) Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit&, mozilla::media::TimeUnit&>(mozilla::media::TimeUnit&, mozilla::media::TimeUnit&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Interval<int&, int&>(int&, int&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Interval<int const&, int const&>(int const&, int const&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval<int, int>(int&&, int&&) Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::Interval<Foo<int>, Foo<int> >(Foo<int>&&, Foo<int>&&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval<int&, int&>(int&, int&) |
58 | | |
59 | | template<typename StartArg, typename EndArg, typename FuzzArg> |
60 | | Interval(StartArg&& aStart, EndArg&& aEnd, FuzzArg&& aFuzz) |
61 | | : mStart(std::forward<StartArg>(aStart)) |
62 | | , mEnd(std::forward<EndArg>(aEnd)) |
63 | | , mFuzz(std::forward<FuzzArg>(aFuzz)) |
64 | 0 | { |
65 | 0 | MOZ_ASSERT(aStart <= aEnd); |
66 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&>(mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&, mozilla::media::TimeUnit const&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Interval<int const&, int const&, int const&>(int const&, int const&, int const&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval<int const&, int const&, int const&>(int const&, int const&, int const&) Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval<mozilla::media::TimeUnit, mozilla::media::TimeUnit, mozilla::media::TimeUnit>(mozilla::media::TimeUnit&&, mozilla::media::TimeUnit&&, mozilla::media::TimeUnit&&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval<int, int, int>(int&&, int&&, int&&) |
67 | | |
68 | | Interval(const SelfType& aOther) |
69 | | : mStart(aOther.mStart) |
70 | | , mEnd(aOther.mEnd) |
71 | | , mFuzz(aOther.mFuzz) |
72 | 0 | { } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval(mozilla::media::Interval<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::Interval<long>::Interval(mozilla::media::Interval<long> const&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval(mozilla::media::Interval<int> const&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Interval(mozilla::media::Interval<unsigned char> const&) Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::Interval(mozilla::media::Interval<Foo<int> > const&) |
73 | | |
74 | | Interval(SelfType&& aOther) |
75 | | : mStart(std::move(aOther.mStart)) |
76 | | , mEnd(std::move(aOther.mEnd)) |
77 | | , mFuzz(std::move(aOther.mFuzz)) |
78 | 0 | { } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Interval(mozilla::media::Interval<mozilla::media::TimeUnit>&&) Unexecuted instantiation: mozilla::media::Interval<long>::Interval(mozilla::media::Interval<long>&&) Unexecuted instantiation: mozilla::media::Interval<int>::Interval(mozilla::media::Interval<int>&&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Interval(mozilla::media::Interval<unsigned char>&&) Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::Interval(mozilla::media::Interval<Foo<int> >&&) |
79 | | |
80 | | SelfType& operator= (const SelfType& aOther) |
81 | | { |
82 | | mStart = aOther.mStart; |
83 | | mEnd = aOther.mEnd; |
84 | | mFuzz = aOther.mFuzz; |
85 | | return *this; |
86 | | } |
87 | | |
88 | | SelfType& operator= (SelfType&& aOther) |
89 | 0 | { |
90 | 0 | MOZ_ASSERT(&aOther != this, "self-moves are prohibited"); |
91 | 0 | this->~Interval(); |
92 | 0 | new(this) Interval(std::move(aOther)); |
93 | 0 | return *this; |
94 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::operator=(mozilla::media::Interval<mozilla::media::TimeUnit>&&) Unexecuted instantiation: mozilla::media::Interval<long>::operator=(mozilla::media::Interval<long>&&) Unexecuted instantiation: mozilla::media::Interval<unsigned char>::operator=(mozilla::media::Interval<unsigned char>&&) Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::operator=(mozilla::media::Interval<Foo<int> >&&) Unexecuted instantiation: mozilla::media::Interval<int>::operator=(mozilla::media::Interval<int>&&) |
95 | | |
96 | | // Basic interval arithmetic operator definition. |
97 | | SelfType operator+ (const SelfType& aOther) const |
98 | | { |
99 | | return SelfType(mStart + aOther.mStart, |
100 | | mEnd + aOther.mEnd, |
101 | | mFuzz + aOther.mFuzz); |
102 | | } |
103 | | |
104 | | SelfType operator+ (const T& aVal) const |
105 | | { |
106 | | return SelfType(mStart + aVal, mEnd + aVal, mFuzz); |
107 | | } |
108 | | |
109 | | // Basic interval arithmetic operator definition. |
110 | | SelfType operator- (const SelfType& aOther) const |
111 | | { |
112 | | return SelfType(mStart - aOther.mEnd, |
113 | | mEnd - aOther.mStart, |
114 | | mFuzz + aOther.mFuzz); |
115 | | } |
116 | | |
117 | | SelfType operator- (const T& aVal) const |
118 | | { |
119 | | return SelfType(mStart - aVal, mEnd - aVal, mFuzz); |
120 | | } |
121 | | |
122 | | bool operator== (const SelfType& aOther) const |
123 | 0 | { |
124 | 0 | return mStart == aOther.mStart && mEnd == aOther.mEnd; |
125 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::operator==(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::operator==(mozilla::media::Interval<int> const&) const |
126 | | |
127 | | bool operator!= (const SelfType& aOther) const |
128 | 0 | { |
129 | 0 | return !(*this == aOther); |
130 | 0 | } |
131 | | |
132 | | bool Contains(const T& aX) const |
133 | 0 | { |
134 | 0 | return mStart - mFuzz <= aX && aX < mEnd + mFuzz; |
135 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Contains(mozilla::media::TimeUnit const&) const Unexecuted instantiation: mozilla::media::Interval<int>::Contains(int const&) const |
136 | | |
137 | | bool ContainsStrict(const T& aX) const |
138 | | { |
139 | | return mStart <= aX && aX < mEnd; |
140 | | } |
141 | | |
142 | | bool ContainsWithStrictEnd(const T& aX) const |
143 | | { |
144 | | return mStart - mFuzz <= aX && aX < mEnd; |
145 | | } |
146 | | |
147 | | bool Contains(const SelfType& aOther) const |
148 | 0 | { |
149 | 0 | return (mStart - mFuzz <= aOther.mStart + aOther.mFuzz) && |
150 | 0 | (aOther.mEnd - aOther.mFuzz <= mEnd + mFuzz); |
151 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Contains(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::Contains(mozilla::media::Interval<int> const&) const |
152 | | |
153 | | bool ContainsStrict(const SelfType& aOther) const |
154 | | { |
155 | | return mStart <= aOther.mStart && aOther.mEnd <= mEnd; |
156 | | } |
157 | | |
158 | | bool ContainsWithStrictEnd(const SelfType& aOther) const |
159 | | { |
160 | | return (mStart - mFuzz <= aOther.mStart + aOther.mFuzz) && |
161 | | aOther.mEnd <= mEnd; |
162 | | } |
163 | | |
164 | | bool Intersects(const SelfType& aOther) const |
165 | 0 | { |
166 | 0 | return (mStart - mFuzz < aOther.mEnd + aOther.mFuzz) && |
167 | 0 | (aOther.mStart - aOther.mFuzz < mEnd + mFuzz); |
168 | 0 | } |
169 | | |
170 | | bool IntersectsStrict(const SelfType& aOther) const |
171 | 0 | { |
172 | 0 | return mStart < aOther.mEnd && aOther.mStart < mEnd; |
173 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::IntersectsStrict(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::IntersectsStrict(mozilla::media::Interval<int> const&) const |
174 | | |
175 | | // Same as Intersects, but including the boundaries. |
176 | | bool Touches(const SelfType& aOther) const |
177 | 0 | { |
178 | 0 | return (mStart - mFuzz <= aOther.mEnd + aOther.mFuzz) && |
179 | 0 | (aOther.mStart - aOther.mFuzz <= mEnd + mFuzz); |
180 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Touches(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<long>::Touches(mozilla::media::Interval<long> const&) const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Touches(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::Touches(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::Touches(mozilla::media::Interval<Foo<int> > const&) const |
181 | | |
182 | | // Returns true if aOther is strictly to the right of this and contiguous. |
183 | | // This operation isn't commutative. |
184 | | bool Contiguous(const SelfType& aOther) const |
185 | 0 | { |
186 | 0 | return mEnd <= aOther.mStart && aOther.mStart - mEnd <= mFuzz + aOther.mFuzz; |
187 | 0 | } |
188 | | |
189 | | bool RightOf(const SelfType& aOther) const |
190 | 0 | { |
191 | 0 | return aOther.mEnd - aOther.mFuzz <= mStart + mFuzz; |
192 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::RightOf(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<long>::RightOf(mozilla::media::Interval<long> const&) const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::RightOf(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::RightOf(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::RightOf(mozilla::media::Interval<Foo<int> > const&) const |
193 | | |
194 | | bool LeftOf(const SelfType& aOther) const |
195 | 0 | { |
196 | 0 | return mEnd - mFuzz <= aOther.mStart + aOther.mFuzz; |
197 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::LeftOf(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<long>::LeftOf(mozilla::media::Interval<long> const&) const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::LeftOf(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::LeftOf(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::LeftOf(mozilla::media::Interval<Foo<int> > const&) const |
198 | | |
199 | | SelfType Span(const SelfType& aOther) const |
200 | 0 | { |
201 | 0 | if (IsEmpty()) { |
202 | 0 | return aOther; |
203 | 0 | } |
204 | 0 | SelfType result(*this); |
205 | 0 | if (aOther.mStart < mStart) { |
206 | 0 | result.mStart = aOther.mStart; |
207 | 0 | } |
208 | 0 | if (mEnd < aOther.mEnd) { |
209 | 0 | result.mEnd = aOther.mEnd; |
210 | 0 | } |
211 | 0 | if (mFuzz < aOther.mFuzz) { |
212 | 0 | result.mFuzz = aOther.mFuzz; |
213 | 0 | } |
214 | 0 | return result; |
215 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Span(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<long>::Span(mozilla::media::Interval<long> const&) const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::Span(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::Span(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::Span(mozilla::media::Interval<Foo<int> > const&) const |
216 | | |
217 | | SelfType Intersection(const SelfType& aOther) const |
218 | 0 | { |
219 | 0 | const T& s = std::max(mStart, aOther.mStart); |
220 | 0 | const T& e = std::min(mEnd, aOther.mEnd); |
221 | 0 | const T& f = std::max(mFuzz, aOther.mFuzz); |
222 | 0 | if (s < e) { |
223 | 0 | return SelfType(s, e, f); |
224 | 0 | } |
225 | 0 | // Return an empty interval. |
226 | 0 | return SelfType(); |
227 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Intersection(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::Intersection(mozilla::media::Interval<int> const&) const |
228 | | |
229 | | T Length() const |
230 | 0 | { |
231 | 0 | return mEnd - mStart; |
232 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::Length() const Unexecuted instantiation: mozilla::media::Interval<int>::Length() const |
233 | | |
234 | | bool IsEmpty() const |
235 | 0 | { |
236 | 0 | return mStart == mEnd; |
237 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::IsEmpty() const Unexecuted instantiation: mozilla::media::Interval<long>::IsEmpty() const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::IsEmpty() const Unexecuted instantiation: mozilla::media::Interval<int>::IsEmpty() const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::IsEmpty() const |
238 | | |
239 | | void SetFuzz(const T& aFuzz) |
240 | 0 | { |
241 | 0 | mFuzz = aFuzz; |
242 | 0 | } |
243 | | |
244 | | // Returns true if the two intervals intersect with this being on the right |
245 | | // of aOther |
246 | | bool TouchesOnRight(const SelfType& aOther) const |
247 | 0 | { |
248 | 0 | return aOther.mStart <= mStart && |
249 | 0 | (mStart - mFuzz <= aOther.mEnd + aOther.mFuzz) && |
250 | 0 | (aOther.mStart - aOther.mFuzz <= mEnd + mFuzz); |
251 | 0 | } Unexecuted instantiation: mozilla::media::Interval<mozilla::media::TimeUnit>::TouchesOnRight(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::Interval<long>::TouchesOnRight(mozilla::media::Interval<long> const&) const Unexecuted instantiation: mozilla::media::Interval<unsigned char>::TouchesOnRight(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::Interval<int>::TouchesOnRight(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::Interval<Foo<int> >::TouchesOnRight(mozilla::media::Interval<Foo<int> > const&) const |
252 | | |
253 | | T mStart; |
254 | | T mEnd; |
255 | | T mFuzz; |
256 | | |
257 | | private: |
258 | | }; |
259 | | |
260 | | // An IntervalSet in a collection of Intervals. The IntervalSet is always |
261 | | // normalized. |
262 | | template<typename T> |
263 | | class IntervalSet |
264 | | { |
265 | | public: |
266 | | typedef IntervalSet<T> SelfType; |
267 | | typedef Interval<T> ElemType; |
268 | | typedef AutoTArray<ElemType,4> ContainerType; |
269 | | typedef typename ContainerType::index_type IndexType; |
270 | | |
271 | | IntervalSet() |
272 | 0 | { |
273 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<int>::IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::IntervalSet() |
274 | | virtual ~IntervalSet() |
275 | 0 | { |
276 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::~IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::~IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<int>::~IntervalSet() Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::~IntervalSet() |
277 | | |
278 | | IntervalSet(const SelfType& aOther) |
279 | | : mIntervals(aOther.mIntervals) |
280 | 0 | { |
281 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::IntervalSet(mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::IntervalSet(mozilla::media::IntervalSet<int> const&) Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::IntervalSet(mozilla::media::IntervalSet<unsigned char> const&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::IntervalSet(mozilla::media::IntervalSet<Foo<int> > const&) |
282 | | |
283 | | IntervalSet(SelfType&& aOther) |
284 | 0 | { |
285 | 0 | mIntervals.AppendElements(std::move(aOther.mIntervals)); |
286 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::IntervalSet(mozilla::media::IntervalSet<mozilla::media::TimeUnit>&&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::IntervalSet(mozilla::media::IntervalSet<int>&&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::IntervalSet(mozilla::media::IntervalSet<Foo<int> >&&) |
287 | | |
288 | | explicit IntervalSet(const ElemType& aOther) |
289 | 0 | { |
290 | 0 | if (!aOther.IsEmpty()) { |
291 | 0 | mIntervals.AppendElement(aOther); |
292 | 0 | } |
293 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::IntervalSet(mozilla::media::Interval<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::IntervalSet(mozilla::media::Interval<unsigned char> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::IntervalSet(mozilla::media::Interval<int> const&) |
294 | | |
295 | | explicit IntervalSet(ElemType&& aOther) |
296 | 0 | { |
297 | 0 | if (!aOther.IsEmpty()) { |
298 | 0 | mIntervals.AppendElement(std::move(aOther)); |
299 | 0 | } |
300 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::IntervalSet(mozilla::media::Interval<mozilla::media::TimeUnit>&&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::IntervalSet(mozilla::media::Interval<int>&&) |
301 | | |
302 | | bool operator== (const SelfType& aOther) const |
303 | 0 | { |
304 | 0 | return mIntervals == aOther.mIntervals; |
305 | 0 | } |
306 | | |
307 | | bool operator!= (const SelfType& aOther) const |
308 | 0 | { |
309 | 0 | return mIntervals != aOther.mIntervals; |
310 | 0 | } |
311 | | |
312 | | SelfType& operator= (const SelfType& aOther) |
313 | 0 | { |
314 | 0 | mIntervals = aOther.mIntervals; |
315 | 0 | return *this; |
316 | 0 | } |
317 | | |
318 | | SelfType& operator= (SelfType&& aOther) |
319 | 0 | { |
320 | 0 | MOZ_ASSERT(&aOther != this, "self-moves are prohibited"); |
321 | 0 | this->~IntervalSet(); |
322 | 0 | new(this) IntervalSet(std::move(aOther)); |
323 | 0 | return *this; |
324 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::operator=(mozilla::media::IntervalSet<mozilla::media::TimeUnit>&&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::operator=(mozilla::media::IntervalSet<int>&&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::operator=(mozilla::media::IntervalSet<Foo<int> >&&) |
325 | | |
326 | | SelfType& operator= (const ElemType& aInterval) |
327 | | { |
328 | | mIntervals.Clear(); |
329 | | if (!aInterval.IsEmpty()) { |
330 | | mIntervals.AppendElement(aInterval); |
331 | | } |
332 | | return *this; |
333 | | } |
334 | | |
335 | | SelfType& operator= (ElemType&& aInterval) |
336 | 0 | { |
337 | 0 | mIntervals.Clear(); |
338 | 0 | if (!aInterval.IsEmpty()) { |
339 | 0 | mIntervals.AppendElement(std::move(aInterval)); |
340 | 0 | } |
341 | 0 | return *this; |
342 | 0 | } |
343 | | |
344 | | SelfType& Add(const SelfType& aIntervals) |
345 | 0 | { |
346 | 0 | mIntervals.AppendElements(aIntervals.mIntervals); |
347 | 0 | Normalize(); |
348 | 0 | return *this; |
349 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::Add(mozilla::media::IntervalSet<unsigned char> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::Add(mozilla::media::IntervalSet<int> const&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::Add(mozilla::media::IntervalSet<Foo<int> > const&) |
350 | | |
351 | | SelfType& Add(const ElemType& aInterval) |
352 | 0 | { |
353 | 0 | if (aInterval.IsEmpty()) { |
354 | 0 | return *this; |
355 | 0 | } |
356 | 0 | if (mIntervals.IsEmpty()) { |
357 | 0 | mIntervals.AppendElement(aInterval); |
358 | 0 | return *this; |
359 | 0 | } |
360 | 0 | ElemType& last = mIntervals.LastElement(); |
361 | 0 | if (aInterval.TouchesOnRight(last)) { |
362 | 0 | last = last.Span(aInterval); |
363 | 0 | return *this; |
364 | 0 | } |
365 | 0 | // Most of our actual usage is adding an interval that will be outside the |
366 | 0 | // range. We can speed up normalization here. |
367 | 0 | if (aInterval.RightOf(last)) { |
368 | 0 | mIntervals.AppendElement(aInterval); |
369 | 0 | return *this; |
370 | 0 | } |
371 | 0 | |
372 | 0 | ContainerType normalized; |
373 | 0 | ElemType current(aInterval); |
374 | 0 | IndexType i = 0; |
375 | 0 | for (; i < mIntervals.Length(); i++) { |
376 | 0 | ElemType& interval = mIntervals[i]; |
377 | 0 | if (current.Touches(interval)) { |
378 | 0 | current = current.Span(interval); |
379 | 0 | } else if (current.LeftOf(interval)) { |
380 | 0 | break; |
381 | 0 | } else { |
382 | 0 | normalized.AppendElement(std::move(interval)); |
383 | 0 | } |
384 | 0 | } |
385 | 0 | normalized.AppendElement(std::move(current)); |
386 | 0 | for (; i < mIntervals.Length(); i++) { |
387 | 0 | normalized.AppendElement(std::move(mIntervals[i])); |
388 | 0 | } |
389 | 0 | mIntervals.Clear(); |
390 | 0 | mIntervals.AppendElements(std::move(normalized)); |
391 | 0 |
|
392 | 0 | return *this; |
393 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::Add(mozilla::media::Interval<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<long>::Add(mozilla::media::Interval<long> const&) Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::Add(mozilla::media::Interval<unsigned char> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::Add(mozilla::media::Interval<int> const&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::Add(mozilla::media::Interval<Foo<int> > const&) |
394 | | |
395 | | SelfType& operator+= (const SelfType& aIntervals) |
396 | 0 | { |
397 | 0 | Add(aIntervals); |
398 | 0 | return *this; |
399 | 0 | } |
400 | | |
401 | | SelfType& operator+= (const ElemType& aInterval) |
402 | 0 | { |
403 | 0 | Add(aInterval); |
404 | 0 | return *this; |
405 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::operator+=(mozilla::media::Interval<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<long>::operator+=(mozilla::media::Interval<long> const&) Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::operator+=(mozilla::media::Interval<unsigned char> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::operator+=(mozilla::media::Interval<int> const&) Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::operator+=(mozilla::media::Interval<Foo<int> > const&) |
406 | | |
407 | | SelfType operator+ (const SelfType& aIntervals) const |
408 | 0 | { |
409 | 0 | SelfType intervals(*this); |
410 | 0 | intervals.Add(aIntervals); |
411 | 0 | return intervals; |
412 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<int>::operator+(mozilla::media::IntervalSet<int> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::operator+(mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&) const |
413 | | |
414 | | SelfType operator+ (const ElemType& aInterval) const |
415 | 0 | { |
416 | 0 | SelfType intervals(*this); |
417 | 0 | intervals.Add(aInterval); |
418 | 0 | return intervals; |
419 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::operator+(mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<int>::operator+(mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::operator+(mozilla::media::Interval<Foo<int> > const&) const |
420 | | |
421 | | friend SelfType operator+ (const ElemType& aInterval, |
422 | | const SelfType& aIntervals) |
423 | 0 | { |
424 | 0 | SelfType intervals; |
425 | 0 | intervals.Add(aInterval); |
426 | 0 | intervals.Add(aIntervals); |
427 | 0 | return intervals; |
428 | 0 | } Unexecuted instantiation: mozilla::media::operator+(mozilla::media::Interval<unsigned char> const&, mozilla::media::IntervalSet<unsigned char> const&) Unexecuted instantiation: mozilla::media::operator+(mozilla::media::Interval<mozilla::media::TimeUnit> const&, mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::operator+(mozilla::media::Interval<int> const&, mozilla::media::IntervalSet<int> const&) Unexecuted instantiation: mozilla::media::operator+(mozilla::media::Interval<Foo<int> > const&, mozilla::media::IntervalSet<Foo<int> > const&) |
429 | | |
430 | | // Excludes an interval from an IntervalSet. |
431 | | // This is done by inverting aInterval within the bounds of mIntervals |
432 | | // and then doing the intersection. |
433 | | SelfType& operator-= (const ElemType& aInterval) |
434 | 0 | { |
435 | 0 | if (aInterval.IsEmpty() || mIntervals.IsEmpty()) { |
436 | 0 | return *this; |
437 | 0 | } |
438 | 0 | T firstEnd = std::max(mIntervals[0].mStart, aInterval.mStart); |
439 | 0 | T secondStart = std::min(mIntervals.LastElement().mEnd, aInterval.mEnd); |
440 | 0 | ElemType startInterval(mIntervals[0].mStart, firstEnd); |
441 | 0 | ElemType endInterval(secondStart, mIntervals.LastElement().mEnd); |
442 | 0 | SelfType intervals(std::move(startInterval)); |
443 | 0 | intervals += std::move(endInterval); |
444 | 0 | return Intersection(intervals); |
445 | 0 | } |
446 | | |
447 | | SelfType& operator-= (const SelfType& aIntervals) |
448 | 0 | { |
449 | 0 | for (const auto& interval : aIntervals.mIntervals) { |
450 | 0 | *this -= interval; |
451 | 0 | } |
452 | 0 | return *this; |
453 | 0 | } |
454 | | |
455 | | SelfType operator- (const SelfType& aInterval) const |
456 | | { |
457 | | SelfType intervals(*this); |
458 | | intervals -= aInterval; |
459 | | return intervals; |
460 | | } |
461 | | |
462 | | SelfType operator- (const ElemType& aInterval) const |
463 | | { |
464 | | SelfType intervals(*this); |
465 | | intervals -= aInterval; |
466 | | return intervals; |
467 | | } |
468 | | |
469 | | // Mutate this IntervalSet to be the union of this and aOther. |
470 | | SelfType& Union(const SelfType& aOther) |
471 | 0 | { |
472 | 0 | Add(aOther); |
473 | 0 | return *this; |
474 | 0 | } |
475 | | |
476 | | SelfType& Union(const ElemType& aInterval) |
477 | | { |
478 | | Add(aInterval); |
479 | | return *this; |
480 | | } |
481 | | |
482 | | // Mutate this TimeRange to be the intersection of this and aOther. |
483 | | SelfType& Intersection(const SelfType& aOther) |
484 | 0 | { |
485 | 0 | ContainerType intersection; |
486 | 0 |
|
487 | 0 | const ContainerType& other = aOther.mIntervals; |
488 | 0 | IndexType i = 0, j = 0; |
489 | 0 | for (; i < mIntervals.Length() && j < other.Length();) { |
490 | 0 | if (mIntervals[i].IntersectsStrict(other[j])) { |
491 | 0 | intersection.AppendElement(mIntervals[i].Intersection(other[j])); |
492 | 0 | } |
493 | 0 | if (mIntervals[i].mEnd < other[j].mEnd) { |
494 | 0 | i++; |
495 | 0 | } else { |
496 | 0 | j++; |
497 | 0 | } |
498 | 0 | } |
499 | 0 | mIntervals.Clear(); |
500 | 0 | mIntervals.AppendElements(std::move(intersection)); |
501 | 0 | return *this; |
502 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::Intersection(mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int>::Intersection(mozilla::media::IntervalSet<int> const&) |
503 | | |
504 | | SelfType& Intersection(const ElemType& aInterval) |
505 | 0 | { |
506 | 0 | SelfType intervals(aInterval); |
507 | 0 | return Intersection(intervals); |
508 | 0 | } |
509 | | |
510 | | const ElemType& operator[] (IndexType aIndex) const |
511 | 0 | { |
512 | 0 | return mIntervals[aIndex]; |
513 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<int>::operator[](unsigned long) const Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::operator[](unsigned long) const |
514 | | |
515 | | // Returns the start boundary of the first interval. Or a default constructed |
516 | | // T if IntervalSet is empty (and aExists if provided will be set to false). |
517 | | T GetStart(bool* aExists = nullptr) const |
518 | 0 | { |
519 | 0 | bool exists = !mIntervals.IsEmpty(); |
520 | 0 |
|
521 | 0 | if (aExists) { |
522 | 0 | *aExists = exists; |
523 | 0 | } |
524 | 0 |
|
525 | 0 | if (exists) { |
526 | 0 | return mIntervals[0].mStart; |
527 | 0 | } else { |
528 | 0 | return T(); |
529 | 0 | } |
530 | 0 | } |
531 | | |
532 | | // Returns the end boundary of the last interval. Or a default constructed T |
533 | | // if IntervalSet is empty (and aExists if provided will be set to false). |
534 | | T GetEnd(bool* aExists = nullptr) const |
535 | 0 | { |
536 | 0 | bool exists = !mIntervals.IsEmpty(); |
537 | 0 | if (aExists) { |
538 | 0 | *aExists = exists; |
539 | 0 | } |
540 | 0 |
|
541 | 0 | if (exists) { |
542 | 0 | return mIntervals.LastElement().mEnd; |
543 | 0 | } else { |
544 | 0 | return T(); |
545 | 0 | } |
546 | 0 | } |
547 | | |
548 | | IndexType Length() const |
549 | 0 | { |
550 | 0 | return mIntervals.Length(); |
551 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::Length() const Unexecuted instantiation: mozilla::media::IntervalSet<int>::Length() const Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::Length() const |
552 | | |
553 | | T Start(IndexType aIndex) const |
554 | 0 | { |
555 | 0 | return mIntervals[aIndex].mStart; |
556 | 0 | } |
557 | | |
558 | | T Start(IndexType aIndex, bool& aExists) const |
559 | | { |
560 | | aExists = aIndex < mIntervals.Length(); |
561 | | |
562 | | if (aExists) { |
563 | | return mIntervals[aIndex].mStart; |
564 | | } else { |
565 | | return T(); |
566 | | } |
567 | | } |
568 | | |
569 | | T End(IndexType aIndex) const |
570 | 0 | { |
571 | 0 | return mIntervals[aIndex].mEnd; |
572 | 0 | } |
573 | | |
574 | | T End(IndexType aIndex, bool& aExists) const |
575 | | { |
576 | | aExists = aIndex < mIntervals.Length(); |
577 | | |
578 | | if (aExists) { |
579 | | return mIntervals[aIndex].mEnd; |
580 | | } else { |
581 | | return T(); |
582 | | } |
583 | | } |
584 | | |
585 | | bool Contains(const ElemType& aInterval) const |
586 | 0 | { |
587 | 0 | for (const auto& interval : mIntervals) { |
588 | 0 | if (interval.Contains(aInterval)) { |
589 | 0 | return true; |
590 | 0 | } |
591 | 0 | } |
592 | 0 | return false; |
593 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit>::Contains(mozilla::media::Interval<mozilla::media::TimeUnit> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<int>::Contains(mozilla::media::Interval<int> const&) const |
594 | | |
595 | | bool ContainsStrict(const ElemType& aInterval) const |
596 | | { |
597 | | for (const auto& interval : mIntervals) { |
598 | | if (interval.ContainsStrict(aInterval)) { |
599 | | return true; |
600 | | } |
601 | | } |
602 | | return false; |
603 | | } |
604 | | |
605 | | bool Contains(const T& aX) const |
606 | 0 | { |
607 | 0 | for (const auto& interval : mIntervals) |
608 | 0 | { |
609 | 0 | if (interval.Contains(aX)) { |
610 | 0 | return true; |
611 | 0 | } |
612 | 0 | } |
613 | 0 | return false; |
614 | 0 | } |
615 | | |
616 | | bool ContainsStrict(const T& aX) const |
617 | | { |
618 | | for (const auto& interval : mIntervals) { |
619 | | if (interval.ContainsStrict(aX)) { |
620 | | return true; |
621 | | } |
622 | | } |
623 | | return false; |
624 | | } |
625 | | |
626 | | bool ContainsWithStrictEnd(const T& aX) const |
627 | | { |
628 | | for (const auto& interval : mIntervals) { |
629 | | if (interval.ContainsWithStrictEnd(aX)) { |
630 | | return true; |
631 | | } |
632 | | } |
633 | | return false; |
634 | | } |
635 | | |
636 | | bool ContainsWithStrictEnd(const ElemType& aInterval) const |
637 | | { |
638 | | for (const auto& interval : mIntervals) { |
639 | | if (interval.ContainsWithStrictEnd(aInterval)) { |
640 | | return true; |
641 | | } |
642 | | } |
643 | | return false; |
644 | | } |
645 | | |
646 | | // Shift all values by aOffset. |
647 | | SelfType& Shift(const T& aOffset) |
648 | 0 | { |
649 | 0 | for (auto& interval : mIntervals) { |
650 | 0 | interval.mStart = interval.mStart + aOffset; |
651 | 0 | interval.mEnd = interval.mEnd + aOffset; |
652 | 0 | } |
653 | 0 | return *this; |
654 | 0 | } |
655 | | |
656 | | void SetFuzz(const T& aFuzz) |
657 | 0 | { |
658 | 0 | for (auto& interval : mIntervals) { |
659 | 0 | interval.SetFuzz(aFuzz); |
660 | 0 | } |
661 | 0 | Normalize(); |
662 | 0 | } |
663 | | |
664 | | static const IndexType NoIndex = IndexType(-1); |
665 | | |
666 | | IndexType Find(const T& aValue) const |
667 | | { |
668 | | for (IndexType i = 0; i < mIntervals.Length(); i++) { |
669 | | if (mIntervals[i].Contains(aValue)) { |
670 | | return i; |
671 | | } |
672 | | } |
673 | | return NoIndex; |
674 | | } |
675 | | |
676 | | // Methods for range-based for loops. |
677 | | typename ContainerType::iterator begin() |
678 | 0 | { |
679 | 0 | return mIntervals.begin(); |
680 | 0 | } |
681 | | |
682 | | typename ContainerType::const_iterator begin() const |
683 | 0 | { |
684 | 0 | return mIntervals.begin(); |
685 | 0 | } |
686 | | |
687 | | typename ContainerType::iterator end() |
688 | 0 | { |
689 | 0 | return mIntervals.end(); |
690 | 0 | } |
691 | | |
692 | | typename ContainerType::const_iterator end() const |
693 | 0 | { |
694 | 0 | return mIntervals.end(); |
695 | 0 | } |
696 | | |
697 | | ElemType& LastInterval() |
698 | | { |
699 | | MOZ_ASSERT(!mIntervals.IsEmpty()); |
700 | | return mIntervals.LastElement(); |
701 | | } |
702 | | |
703 | | const ElemType& LastInterval() const |
704 | | { |
705 | | MOZ_ASSERT(!mIntervals.IsEmpty()); |
706 | | return mIntervals.LastElement(); |
707 | | } |
708 | | |
709 | | void Clear() |
710 | 0 | { |
711 | 0 | mIntervals.Clear(); |
712 | 0 | } |
713 | | |
714 | | protected: |
715 | | ContainerType mIntervals; |
716 | | |
717 | | private: |
718 | | void Normalize() |
719 | 0 | { |
720 | 0 | if (mIntervals.Length() >= 2) { |
721 | 0 | ContainerType normalized; |
722 | 0 |
|
723 | 0 | mIntervals.Sort(CompareIntervals()); |
724 | 0 |
|
725 | 0 | // This merges the intervals. |
726 | 0 | ElemType current(mIntervals[0]); |
727 | 0 | for (IndexType i = 1; i < mIntervals.Length(); i++) { |
728 | 0 | ElemType& interval = mIntervals[i]; |
729 | 0 | if (current.Touches(interval)) { |
730 | 0 | current = current.Span(interval); |
731 | 0 | } else { |
732 | 0 | normalized.AppendElement(std::move(current)); |
733 | 0 | current = std::move(interval); |
734 | 0 | } |
735 | 0 | } |
736 | 0 | normalized.AppendElement(std::move(current)); |
737 | 0 |
|
738 | 0 | mIntervals.Clear(); |
739 | 0 | mIntervals.AppendElements(std::move(normalized)); |
740 | 0 | } |
741 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::Normalize() Unexecuted instantiation: mozilla::media::IntervalSet<int>::Normalize() Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::Normalize() |
742 | | |
743 | | struct CompareIntervals |
744 | | { |
745 | | bool Equals(const ElemType& aT1, const ElemType& aT2) const |
746 | 0 | { |
747 | 0 | return aT1.mStart == aT2.mStart && aT1.mEnd == aT2.mEnd; |
748 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::CompareIntervals::Equals(mozilla::media::Interval<unsigned char> const&, mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<int>::CompareIntervals::Equals(mozilla::media::Interval<int> const&, mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::CompareIntervals::Equals(mozilla::media::Interval<Foo<int> > const&, mozilla::media::Interval<Foo<int> > const&) const |
749 | | |
750 | 0 | bool LessThan(const ElemType& aT1, const ElemType& aT2) const { |
751 | 0 | return aT1.mStart - aT1.mFuzz < aT2.mStart + aT2.mFuzz; |
752 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<unsigned char>::CompareIntervals::LessThan(mozilla::media::Interval<unsigned char> const&, mozilla::media::Interval<unsigned char> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<int>::CompareIntervals::LessThan(mozilla::media::Interval<int> const&, mozilla::media::Interval<int> const&) const Unexecuted instantiation: mozilla::media::IntervalSet<Foo<int> >::CompareIntervals::LessThan(mozilla::media::Interval<Foo<int> > const&, mozilla::media::Interval<Foo<int> > const&) const |
753 | | }; |
754 | | }; |
755 | | |
756 | | // clang doesn't allow for this to be defined inline of IntervalSet. |
757 | | template<typename T> |
758 | | IntervalSet<T> Union(const IntervalSet<T>& aIntervals1, |
759 | | const IntervalSet<T>& aIntervals2) |
760 | 0 | { |
761 | 0 | IntervalSet<T> intervals(aIntervals1); |
762 | 0 | intervals.Union(aIntervals2); |
763 | 0 | return intervals; |
764 | 0 | } |
765 | | |
766 | | template<typename T> |
767 | | IntervalSet<T> Intersection(const IntervalSet<T>& aIntervals1, |
768 | | const IntervalSet<T>& aIntervals2) |
769 | 0 | { |
770 | 0 | IntervalSet<T> intersection(aIntervals1); |
771 | 0 | intersection.Intersection(aIntervals2); |
772 | 0 | return intersection; |
773 | 0 | } Unexecuted instantiation: mozilla::media::IntervalSet<mozilla::media::TimeUnit> mozilla::media::Intersection<mozilla::media::TimeUnit>(mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&, mozilla::media::IntervalSet<mozilla::media::TimeUnit> const&) Unexecuted instantiation: mozilla::media::IntervalSet<int> mozilla::media::Intersection<int>(mozilla::media::IntervalSet<int> const&, mozilla::media::IntervalSet<int> const&) |
774 | | |
775 | | } // namespace media |
776 | | } // namespace mozilla |
777 | | |
778 | | #endif // INTERVALS_H |