Dockyard > Objective-C Classes > NSIndexSetEnumerator

NSIndexSetEnumerator

Class Description


I made a little class to help me around some of my confusions regarding NSIndexSet. This class allows you to enumerate through an NSIndexSet using the Apple-suggested method of -(unsigned int)getIndexes:(unsigned int *)indexBuffer maxCount:(unsigned int)bufferSize inIndexRange:(NSRangePointer)range using simple enumerator-like messages. Currently it doesn't support buffering (ie. if you have an IndexSet with one million entries, you'll end up with an internal array of one million entries), but it seems to work ok for what it is. Please note that this is NOT rigorously tested or supported code, I just thought I'd share something that made my life a little easier (note also the extreme lack of code comments :-) ) but the code is relatively self explanatory (I hope!). (docs from http://www.cocoadev.com/index.pl?NSIndexSet / further docs added by Belkadan Software)

By Darren Ford

Methods


- count

- indexAtIndex:

- initWithIndexSet:

- initWithIndexSet:range:

- nextIndex:

- reset

Method Detail


count

- (unsigned int)count

Returns the total number of indexes.

indexAtIndex:

- (unsigned int)indexAtIndex:(unsigned int)i

Returns the i'th index in the list of indexes. If i is greater than the number of indexes, returns NSNotFound.

initWithIndexSet:

- (id)initWithIndexSet:(NSIndexSet *)theSet

Initializes and returns a newly allocated enumerator with the specified NSIndexSet.

initWithIndexSet:range:

- (id)initWithIndexSet:(NSIndexSet *)theSet range:(NSRange)myRange

Initializes and returns a newly allocated enumerator with the specified NSIndexSet and range. This enumerator will only enumerate the indexes in myRange. This is the designated initializer.

nextIndex:

- (BOOL)nextIndex:(unsigned int *)pValue

Provides the next index by means of the pValue pointer. Returns YES if an index was placed in pValue, NO if there are no more indexes.

reset

- (void)reset

Starts the enumerator back at the beginning of the list.

This page was generated with DocYouMeant, a program created by Belkadan Software

Valid XHTML 1.0! Valid CSS!