Instance Method

indexOfObject:inSortedRange:options:usingComparator:

Returns the index, within a specified range, of an object compared with elements in the ordered set using a given NSComparator block.

Declaration

- (NSUInteger)indexOfObject:(ObjectType)object inSortedRange:(NSRange)range options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp;

Parameters

object

An object for which to search in the ordered set.

If this value is nil, throws an NSInvalidArgumentException.

range

The range within the array to search for object.

If r exceeds the bounds of the ordered set (if the location plus length of the range is greater than the count of the ordered set), throws an NSRangeException.

opts

Options for the search. For possible values, see NSBinarySearchingOptions.

cmp

A comparator block used to compare the object obj with elements in the ordered set.

If this value is NULL, throws an NSInvalidArgumentException.

Return Value

If the NSBinarySearchingInsertionIndex option is not specified:

If the NSBinarySearchingInsertionIndex option is specified, returns the index at which you should insert obj in order to maintain a sorted array:

Discussion

The elements in the ordered set must have already been sorted using the comparator cmp. If the ordered set is not sorted, the result is undefined.

See Also

Accessing Set Members

- containsObject:

Returns a Boolean value that indicates whether a given object is present in the ordered set.

- enumerateObjectsAtIndexes:options:usingBlock:

Executes a given block using the objects in the ordered set at the specified indexes.

- enumerateObjectsUsingBlock:

Executes a given block using each object in the ordered set.

- enumerateObjectsWithOptions:usingBlock:

Executes a given block using each object in the set, using the specified enumeration options.

firstObject

The first object in the ordered set.

lastObject

The last object in the ordered set.

- objectAtIndex:

Returns the object at the specified index of the set.

- objectAtIndexedSubscript:

Returns the object at the specified index of the set.

- objectsAtIndexes:

Returns the objects in the ordered set at the specified indexes.

- indexOfObject:

Returns the index of the specified object.

- indexOfObjectAtIndexes:options:passingTest:

Returns the index, from a given set of indexes, of the object in the ordered set that passes a test in a given block for a given set of enumeration options.

- indexOfObjectPassingTest:

Returns the index of the object in the ordered set that passes a test in a given block.

- indexOfObjectWithOptions:passingTest:

Returns the index of an object in the ordered set that passes a test in a given block for a given set of enumeration options.

- indexesOfObjectsAtIndexes:options:passingTest:

Returns the index, from a given set of indexes, of the object in the ordered set that passes a test in a given block for a given set of enumeration options.

- indexesOfObjectsPassingTest:

Returns the index of the object in the ordered set that passes a test in a given block.

- indexesOfObjectsWithOptions:passingTest:

Returns the index of an object in the ordered set that passes a test in a given block for a given set of enumeration options.

- objectEnumerator

Returns an enumerator object that lets you access each object in the ordered set.

- reverseObjectEnumerator

Returns an enumerator object that lets you access each object in the ordered set.

reversedOrderedSet

An ordered set in the reverse order.

- getObjects:range:

Copies the objects contained in the ordered set that fall within the specified range to objects.