This feels like a dumb question because it seems to me like my use case must be quite common.
Say I want to represent a sparse set of indexes with an NSIndexSet (whi
Say I want to represent a sparse set of indexes with an NSIndexSet (which is of course what it's for).
[my emphasis]
Actually, no it's not. The documentation says this:
You should not use index sets to store an arbitrary collection of integer values because index sets store indexes as sorted ranges.
So if you are using it to store a sparse array of integers, it is quite inefficient. Also, the only way to get the nth index is to iterate from one end. You'd be better off using an array.