Как выполнить бинарный поиск на NSArray?
Какой самый простой способ сделать бинарный поиск по (уже) отсортированNSArray
?
Некоторые потенциальные способы, которые я обнаружил, включают:
The use ofCFArrayBSearchValues
(mentioned here) - would this work on an NSArray
?
The method indexOfObject:inSortedRange:options:usingComparator:
of NSArray
assumes the array is sorted and takes an opts
param of type NSBinarySearchingOptions
- does this mean it performs a binary search? The docs just say:
Returns the index, within a specified range, of an object compared with elements in the array using a given NSComparator block.
Write my own binary search method (something along the lines of this).
Я должен добавить, что я программирую для iOS 4.3+
Заранее спасибо.