Class: NSIndexSet

Inherits:
NSObject show all

Overview

The NSIndexSet class represents an immutable collection of unique unsigned integers, known as indexes because of the way they are used. This collection is referred to as an index set.

Direct Known Subclasses

NSMutableIndexSet

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (Object) indexSet

Creates an empty index set.

Returns:

+ (Object) indexSetWithIndex(index)

Creates an index set with an index.

Parameters:

Returns:

+ (Object) indexSetWithIndexesInRange(indexRange)

Creates an index set with an index range.

Parameters:

  • indexRange (NSRange)

    An index range.

Returns:

Instance Method Details

- (Boolean) containsIndex(index)

Indicates whether the index set contains a specific index.

Parameters:

  • index (Integer)

    Index being inquired about.

Returns:

  • (Boolean)

    YES when the index set contains index, NO otherwise.

- (Boolean) containsIndexes(indexSet)

Indicates whether the receiving index set contains a superset of the indexes in another index set.

Parameters:

  • indexSet (NSIndexSet)

    Index set being inquired about.

Returns:

  • (Boolean)

    YES when the receiving index set contains a superset of the indexes in indexSet, NO otherwise.

- (Boolean) containsIndexesInRange(indexRange)

Indicates whether the index set contains the indexes represented by an index range.

Parameters:

  • indexRange (NSRange)

    The index range being inquired about.

Returns:

  • (Boolean)

    YES when the index set contains the indexes in indexRange, NO otherwise.

- (Integer) count

Returns the number of indexes in the index set.

Returns:

  • (Integer)

    Number of indexes in the index set.

- (Integer) countOfIndexesInRange(indexRange)

Returns the number of indexes in the index set that are members of a given range.

Parameters:

  • indexRange (NSRange)

    Index range being inquired about.

Returns:

  • (Integer)

    Number of indexes in the index set that are members of indexRange.

- (Object) enumerateIndexesInRange(range, options:opts, usingBlock:block)

Executes a given Block using the indexes in the specified range, using the specified enumeration options.

Parameters:

  • range

    The range to enumerate.

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • block

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Object) enumerateIndexesUsingBlock(block)

Executes a given Block using each object in the index set.

Parameters:

  • block

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Object) enumerateIndexesWithOptions(opts, usingBlock:block)

Executes a given Block over the index set’s indexes, using the specified enumeration options.

Parameters:

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • block

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Object) enumerateRangesInRange(range, options:opts, usingBlock:block)

Enumerates over the ranges in the range of objects using the block By default, the enumeration starts with the first object and continues serially through the indexed set range to the last object in the range. You can specify NSEnumerationConcurrent and/or NSEnumerationReverse as enumeration options to modify this behavior.Important: If the Block parameter is nil this method will raise an exception.

Parameters:

  • range

    The range of items to enumerate. If the range intersects a range of the receiver’s indexes, then that intersection will be passed to the block.

  • opts

    A bitmask that specifies the NSEnumerationOptions for the enumeration.

  • block

    The block to apply to elements in the index set.The block takes two arguments:rangeThe range of elements.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • range

    The range of elements.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Object) enumerateRangesUsingBlock(block)

Executes a given block using each object in the index set, in the specified ranges. If the Block parameter is nil this method will raise an exception.

Parameters:

  • block

    The block to apply to elements in the index set.The block takes two arguments:rangeThe range of objects of the elements in the index set.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • range

    The range of objects of the elements in the index set.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Object) enumerateRangesWithOptions(opts, usingBlock:block)

Executes a given block using each object in the index set, in the specified ranges. By default, the enumeration starts with the first object and continues serially through the indexed set range to the last object in the range. You can specify NSEnumerationConcurrent and/or NSEnumerationReverse as enumeration options to modify this behavior.Important: If the Block parameter is nil this method will raise an exception.

Parameters:

  • opts

    A bitmask that specifies the NSEnumerationOptions for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order).

  • block

    The block to apply to elements in the index set.The block takes two arguments:rangeThe range of objects of the elements in the index set.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

  • range

    The range of objects of the elements in the index set.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the array. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

- (Integer) firstIndex

Returns either the first index in the index set or the not-found indicator.

Returns:

  • (Integer)

    First index in the index set or NSNotFound when the index set is empty.

- (Integer) getIndexes(indexBuffer, maxCount:bufferSize, inIndexRange:indexRangePointer)

The index set fills an index buffer with the indexes contained both in the index set and in an index range, returning the number of indexes copied. You are responsible for allocating the memory required for indexBuffer and for releasing it later.Suppose you have an index set with contiguous indexes from 1 to 100. If you use this method to request a range of (1, 100)—which represents the set of indexes 1 through 100—and specify a buffer size of 20, this method returns 20 indexes—1 through 20—in indexBuffer and sets indexRange to (21, 80)—which represents the indexes 21 through 100.Use this method to retrieve entries quickly and efficiently from an index set. You can call this method repeatedly to retrieve blocks of index values and then process them. When doing so, use the return value and indexRange to determine when you have finished processing the desired indexes. When the return value is less than bufferSize, you have reached the end of the range.

Parameters:

  • indexBuffer (Integer)

    Index buffer to fill.

  • bufferSize (Integer)

    Maximum size of indexBuffer.

  • indexRange (NSRangePointer)

    Index range to compare with indexes in the index set; nil represents all the indexes in the index set. Indexes in the index range and in the index set are copied to indexBuffer. On output, the range of indexes not copied to indexBuffer.

Returns:

  • (Integer)

    Number of indexes placed in indexBuffer.

- (NSIndexSet) indexesInRange(range, options:opts, passingTest:predicate)

Returns an NSIndexSet containing the receiving index set’s objects in the specified range that pass the Block test.

Parameters:

  • range

    The range of indexes to test.

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (NSIndexSet)

    An NSIndexSet containing the indexes of the receiving index set that passed the predicate Block test.

- (NSIndexSet) indexesPassingTest(predicate)

Returns an NSIndexSet containing the receiving index set’s objects that pass the Block test.

Parameters:

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (NSIndexSet)

    An NSIndexSet containing the indexes of the receiving index set that passed the predicate Block test.

- (NSIndexSet) indexesWithOptions(opts, passingTest:predicate)

Returns an NSIndexSet containing the receiving index set’s objects that pass the Block test using the specified enumeration options.

Parameters:

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (NSIndexSet)

    An NSIndexSet containing the indexes of the receiving index set that passed the predicate Block test.

- (Integer) indexGreaterThanIndex(index)

Returns either the closest index in the index set that is greater than a specific index or the not-found indicator.

Parameters:

  • index (Integer)

    Index being inquired about.

Returns:

  • (Integer)

    Closest index in the index set greater than index; NSNotFound when the index set contains no qualifying index.

- (Integer) indexGreaterThanOrEqualToIndex(index)

Returns either the closest index in the index set that is greater than or equal to a specific index or the not-found indicator.

Parameters:

  • index (Integer)

    Index being inquired about.

Returns:

  • (Integer)

    Closest index in the index set greater than or equal to index; NSNotFound when the index set contains no qualifying index.

- (Integer) indexInRange(range, options:opts, passingTest:predicate)

Returns the index of the first object in the specified range that passes the predicate Block test.

Parameters:

  • range

    The range of indexes to test.

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (Integer)

    The index of the first object that passes the predicate test.

- (Integer) indexLessThanIndex(index)

Returns either the closest index in the index set that is less than a specific index or the not-found indicator.

Parameters:

  • index (Integer)

    Index being inquired about.

Returns:

  • (Integer)

    Closest index in the index set less than index; NSNotFound when the index set contains no qualifying index.

- (Integer) indexLessThanOrEqualToIndex(index)

Returns either the closest index in the index set that is less than or equal to a specific index or the not-found indicator.

Parameters:

  • index (Integer)

    Index being inquired about.

Returns:

  • (Integer)

    Closest index in the index set less than or equal to index; NSNotFound when the index set contains no qualifying index.

- (Integer) indexPassingTest(predicate)

Returns the index of the first object that passes the predicate Block test.

Parameters:

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (Integer)

    The index of the first object that passes the predicate test.

- (Integer) indexWithOptions(opts, passingTest:predicate)

Returns the index of the first object that passes the predicate Block test using the specified enumeration options.

Parameters:

  • opts

    A bitmask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). See NSEnumerationOptions for the supported values.

  • predicate

    The Block to apply to elements in the set.The Block takes two arguments:idxThe index of the object.stopA reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.The Block returns a Boolean value that indicates whether obj passed the test.

  • idx

    The index of the object.

  • stop

    A reference to a Boolean value. The block can set the value to YES to stop further processing of the set. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the Block.

Returns:

  • (Integer)

    The index of the first object that passes the predicate test.

- (Object) init

Initializes an allocated NSIndexSet object.

Returns:

- (Object) initWithIndex(index)

Initializes an allocated NSIndexSet object with an index.

Parameters:

Returns:

- (Object) initWithIndexesInRange(indexRange)

Initializes an allocated NSIndexSet object with an index range. This method raises an NSRangeException when indexRange would add an index that exceeds the maximum allowed value for unsigned integers.This method is a designated initializer for NSIndexSet.

Parameters:

  • indexRange (NSRange)

    An index range. Must include only indexes representable as unsigned integers.

Returns:

- (Object) initWithIndexSet(indexSet)

Initializes an allocated NSIndexSet object with an index set. This method is a designated initializer for NSIndexSet.

Parameters:

Returns:

- (Boolean) intersectsIndexesInRange(indexRange)

Indicates whether the index set contains any of the indexes in a range.

Parameters:

  • indexRange (NSRange)

    Index range being inquired about.

Returns:

  • (Boolean)

    YES when the index set contains one or more of the indexes in indexRange, NO otherwise.

- (Boolean) isEqualToIndexSet(indexSet)

Indicates whether the indexes in the receiving index set are the same indexes contained in another index set.

Parameters:

  • indexSet (NSIndexSet)

    Index set being inquired about.

Returns:

  • (Boolean)

    YES when the indexes in the receiving index set are the same indexes indexSet contains, NO otherwise.

- (Integer) lastIndex

Returns either the last index in the index set or the not-found indicator.

Returns:

  • (Integer)

    Last index in the index set or NSNotFound when the index set is empty.