Skip to content

Commit

Permalink
CPAttributedString necessary additions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Oct 23, 2008
1 parent fabd1df commit 5023588
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Foundation/CPDictionary.j
Expand Up @@ -210,6 +210,33 @@ import "CPException.j"
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)
{
Expand Down
12 changes: 12 additions & 0 deletions Foundation/CPRange.j
Expand Up @@ -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
Expand Down

0 comments on commit 5023588

Please sign in to comment.