getIndexes(_:maxCount:inIndexRange:)
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.
Declaration
func getIndexes(_ indexBuffer: UnsafeMutablePointer<Int>, maxCount bufferSize: Int, inIndexRange range: NSRangePointer?) -> IntParameters
- indexBuffer:
Index buffer to fill.
- bufferSize:
Maximum size of
indexBuffer. - range:
Index range to compare with indexes in the index set;
nilrepresents all the indexes in the index set. Indexes in the index range and in the index set are copied toindexBuffer. On output, the range of indexes not copied toindexBuffer.
Return Value
Number of indexes placed in indexBuffer.
Discussion
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.