I need to pick a random index from those included in an NSIndexSet
.
For reference, (It turns out -anyObject is not guaranteed to return a random object from a set.)NSSet
defines the -anyObject
method (documentation) for picking arbitrary objects from a set. Is there a similar functionality in NSIndexSet
?
If not, how could it be implemented?
Note: I have found an implementation here, but it involves iteration over the index set's elements. Ideally I would like to avoid enumeration.
Edit: To my disappointment, the documentation of NSSet
states that -anyObject
is not guaranteed to return a random object from a set. Unfortunately, the same conclusion can be drawn from the NSIndexSet
documentation, regarding the implementation of -getIndexes:maxCount:inIndexRange: