PageRenderTime 19ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/Foundation/objj.platform/CPRange.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 54 lines | 53 code | 1 blank | 0 comment | 0 complexity | c1b6fad1d0e49167a4b741049041b564 MD5 | raw file
 1c;1714;CPMakeRange= function(location, length)
 2{
 3    return { location: location, length: length };
 4}
 5CPCopyRange= function(aRange)
 6{
 7    return { location: aRange.location, length: aRange.length };
 8}
 9CPMakeRangeCopy= function(aRange)
10{
11    return { location:aRange.location, length:aRange.length };
12}
13CPEmptyRange= function(aRange)
14{
15    return aRange.length === 0;
16}
17CPMaxRange= function(aRange)
18{
19    return aRange.location + aRange.length;
20}
21CPEqualRanges= function(lhsRange, rhsRange)
22{
23    return ((lhsRange.location === rhsRange.location) && (lhsRange.length === rhsRange.length));
24}
25CPLocationInRange= function(aLocation, aRange)
26{
27    return (aLocation >= aRange.location) && (aLocation < CPMaxRange(aRange));
28}
29CPUnionRange= function(lhsRange, rhsRange)
30{
31    var location = MIN(lhsRange.location, rhsRange.location);
32    return CPMakeRange(location, MAX(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
33}
34CPIntersectionRange= function(lhsRange, rhsRange)
35{
36    if(CPMaxRange(lhsRange) < rhsRange.location || CPMaxRange(rhsRange) < lhsRange.location)
37        return CPMakeRange(0, 0);
38    var location = MAX(lhsRange.location, rhsRange.location);
39    return CPMakeRange(location, MIN(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
40}
41CPRangeInRange= function(lhsRange, rhsRange)
42{
43    return (lhsRange.location <= rhsRange.location && CPMaxRange(lhsRange) >= CPMaxRange(rhsRange));
44}
45CPStringFromRange= function(aRange)
46{
47    return "{" + aRange.location + ", " + aRange.length + "}";
48}
49CPRangeFromString= function(aString)
50{
51    var comma = aString.indexOf(',');
52    return { location:parseInt(aString.substr(1, comma - 1)), length:parseInt(aString.substring(comma + 1, aString.length)) };
53}
54