| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * Copyright (C) 2007, 2009, 2010 Apple Inc.  All rights reserved. | 2  * Copyright (C) 2007, 2009, 2010 Apple Inc.  All rights reserved. | 
| 3  * | 3  * | 
| 4  * Redistribution and use in source and binary forms, with or without | 4  * Redistribution and use in source and binary forms, with or without | 
| 5  * modification, are permitted provided that the following conditions | 5  * modification, are permitted provided that the following conditions | 
| 6  * are met: | 6  * are met: | 
| 7  * 1. Redistributions of source code must retain the above copyright | 7  * 1. Redistributions of source code must retain the above copyright | 
| 8  *    notice, this list of conditions and the following disclaimer. | 8  *    notice, this list of conditions and the following disclaimer. | 
| 9  * 2. Redistributions in binary form must reproduce the above copyright | 9  * 2. Redistributions in binary form must reproduce the above copyright | 
| 10  *    notice, this list of conditions and the following disclaimer in the | 10  *    notice, this list of conditions and the following disclaimer in the | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 159         } | 159         } | 
| 160     } | 160     } | 
| 161 | 161 | 
| 162     // Now that we are sure we don't overlap with any range, just add it. | 162     // Now that we are sure we don't overlap with any range, just add it. | 
| 163     m_ranges.insert(overlappingArcIndex, addedRange); | 163     m_ranges.insert(overlappingArcIndex, addedRange); | 
| 164 } | 164 } | 
| 165 | 165 | 
| 166 bool TimeRanges::contain(double time) const | 166 bool TimeRanges::contain(double time) const | 
| 167 { | 167 { | 
| 168     for (unsigned n = 0; n < length(); n++) { | 168     for (unsigned n = 0; n < length(); n++) { | 
| 169         if (time >= start(n, IGNORE_EXCEPTION_STATE) && time <= end(n, IGNORE_EX
     CEPTION_STATE)) | 169         if (time >= start(n, IGNORE_EXCEPTION) && time <= end(n, IGNORE_EXCEPTIO
     N)) | 
| 170             return true; | 170             return true; | 
| 171     } | 171     } | 
| 172     return false; | 172     return false; | 
| 173 } | 173 } | 
| 174 | 174 | 
| 175 double TimeRanges::nearest(double time) const | 175 double TimeRanges::nearest(double time) const | 
| 176 { | 176 { | 
| 177     double closest = 0; | 177     double closest = 0; | 
| 178     unsigned count = length(); | 178     unsigned count = length(); | 
| 179     for (unsigned ndx = 0; ndx < count; ndx++) { | 179     for (unsigned ndx = 0; ndx < count; ndx++) { | 
| 180         double startTime = start(ndx, IGNORE_EXCEPTION_STATE); | 180         double startTime = start(ndx, IGNORE_EXCEPTION); | 
| 181         double endTime = end(ndx, IGNORE_EXCEPTION_STATE); | 181         double endTime = end(ndx, IGNORE_EXCEPTION); | 
| 182         if (time >= startTime && time <= endTime) | 182         if (time >= startTime && time <= endTime) | 
| 183             return time; | 183             return time; | 
| 184         if (fabs(startTime - time) < closest) | 184         if (fabs(startTime - time) < closest) | 
| 185             closest = fabsf(startTime - time); | 185             closest = fabsf(startTime - time); | 
| 186         else if (fabs(endTime - time) < closest) | 186         else if (fabs(endTime - time) < closest) | 
| 187             closest = fabsf(endTime - time); | 187             closest = fabsf(endTime - time); | 
| 188     } | 188     } | 
| 189     return closest; | 189     return closest; | 
| 190 } | 190 } | 
| OLD | NEW | 
|---|