mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-01 18:58:22 +00:00
Merge branch 'master' of git@github.com:280north/cappuccino
This commit is contained in:
commit
12b58cd938
3 files changed
+49
-2
No files matched your search
@@ -696,10 +696,10 @@
|
||||
*/
|
||||
- (CPArray)subarrayWithRange:(CPRange)aRange
|
||||
{
|
||||
if (aRange.location < 0 || (aRange.location + CPMaxRange(aRange)) > length)
|
||||
if (aRange.location < 0 || CPMaxRange(aRange) > length)
|
||||
[CPException raise:CPRangeException reason:"subarrayWithRange: aRange out of bounds"];
|
||||
|
||||
return slice(aRange.location, maxRange);
|
||||
return slice(aRange.location, CPMaxRange(aRange));
|
||||
}
|
||||
|
||||
// Sorting arrays
|
||||
|
||||
@@ -164,6 +164,14 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
/*!
|
||||
return a copy of the receiver (does not deep copy the objects contained in the dictionary).
|
||||
*/
|
||||
- (CPDictionary)copy
|
||||
{
|
||||
return [CPDictionary dictionaryWithDictionary:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of entries in the dictionary
|
||||
*/
|
||||
@@ -210,6 +218,33 @@
|
||||
return [[_CPDictionaryValueEnumerator alloc] initWithDictionary:self];
|
||||
}
|
||||
|
||||
/*!
|
||||
Compare the receiver to this dictionary, and return whether or not they are equal.
|
||||
*/
|
||||
- (BOOL)isEqualToDictionary:(CPDictionary)aDictionary
|
||||
{
|
||||
if (count != [aDictionary count])
|
||||
return NO;
|
||||
|
||||
var index = count;
|
||||
while (index--)
|
||||
{
|
||||
var currentKey = _keys[index],
|
||||
lhsObject = _buckets[currentKey],
|
||||
rhsObject = aDictionary._buckets[currentKey];
|
||||
|
||||
if (lhsObject === rhsObject)
|
||||
continue;
|
||||
|
||||
if ([lhsObject respondsToSelector:@selector(isEqual:)] && [lhsObject isEqual:rhsObject])
|
||||
continue;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
Instance.isEqualToDictionary(aDictionary)
|
||||
{
|
||||
|
||||
@@ -129,6 +129,18 @@ function CPIntersectionRange(lhsRange, rhsRange)
|
||||
return CPMakeRange(location, Math.min(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
|
||||
}
|
||||
|
||||
/*!
|
||||
Checks if a range completely contains another range. In other words, if one range is the "super range" of another.
|
||||
@param lhsRange the containing range
|
||||
@param rhsRange the range we are testing to see if lhsRange contains it
|
||||
@group CPRange
|
||||
@return BOOL whether or not lhsRange completely contains rhsRange
|
||||
*/
|
||||
function CPRangeInRange(lhsRange, rhsRange)
|
||||
{
|
||||
return (lhsRange.location <= rhsRange.location && CPMaxRange(lhsRange) >= CPMaxRange(rhsRange));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a string describing a range.
|
||||
@param aRange the range to describe
|
||||
|
||||
Reference in new issue
Block a user