mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 13:07:02 +00:00
Fix remaining failing tests and add indexOfObject:inSortedRange:options:usingComparator:, and removed non-standard methods:
- indexOfObject:sortedBySelector: - indexOfObject:sortedByFunction: - indexOfObject:sortedByDescriptors: - indexOfObject:sortedByFunction:context: Reviewed by me.
This commit is contained in:
@@ -90,31 +90,29 @@
|
||||
|
||||
- (unsigned)insertObject:(id)anObject inArraySortedByDescriptors:(CPArray)descriptors
|
||||
{
|
||||
var count = [descriptors count],
|
||||
index;
|
||||
var index,
|
||||
count = [descriptors count];
|
||||
|
||||
if (count)
|
||||
{
|
||||
// FIXME: UGH
|
||||
index = [self indexOfObject:anObject sortedByFunction:function(lhs, rhs)
|
||||
index = [self indexOfObject:anObject
|
||||
inSortedRange:nil
|
||||
options:CPBinarySearchingInsertionIndex
|
||||
usingComparator:function(lhs, rhs)
|
||||
{
|
||||
var i = 0,
|
||||
var index = 0,
|
||||
result = CPOrderedSame;
|
||||
|
||||
while (i < count)
|
||||
if ((result = [descriptors[i++] compareObject:lhs withObject:rhs]) != CPOrderedSame)
|
||||
return result;
|
||||
while (index < count && ((result = [[descriptors objectAtIndex:index] compareObject:lhs withObject:rhs]) === CPOrderedSame))
|
||||
++index;
|
||||
|
||||
return result;
|
||||
} context:nil];
|
||||
}];
|
||||
|
||||
if (index < 0)
|
||||
index = -index - 1;
|
||||
}
|
||||
else
|
||||
index = self.length;
|
||||
index = [self count];
|
||||
|
||||
[self insertObject:anObject atIndex:index];
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user