This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension RandomAccessCollection { | |
func binarySearch(startIndex: Index? = nil, endIndex: Index? = nil, comparator: (Element) -> Int) -> (index: Index, found: Bool) { | |
var low = startIndex ?? self.startIndex | |
var high = index(before: endIndex ?? self.endIndex) | |
while low <= high { | |
let mid = index(low, offsetBy: distance(from: low, to: high) >> 1) | |
let midVal = self[mid] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"firstName":"Evelina","lastName":"Schoen","email":"vicente.larkin@example.com","login":"Stew Ng","passwordHash":"w!^n@R!4@B#*&4inIF**@O#Ao","gender":"MALE","avatarUrl":"https://s3.amazonaws.com/uifaces/faces/twitter/amandabuzard/128.jpg","country":"Cambodia","city":"Bratislava","zipCode":589927,"phone":"504-641-1740 x3218","isVip":false,"isFamous":false},{"firstName":"Verlie","lastName":"Becker","email":"patria.torphy@example.com","login":"Eve O'Lution","passwordHash":"HxO^fy7lemCj2*jy2whp0Y","gender":"MALE","avatarUrl":"https://s3.amazonaws.com/uifaces/faces/twitter/ernestsemerda/128.jpg","country":"Brunei Darussalam","city":"Buenos Aires","zipCode":181276,"phone":"(906) 860-8891 x4304","isVip":false,"isFamous":false},{"firstName":"Murray","lastName":"Greenholt","email":"charla.daniel@example.com","login":"Brice Tagg","passwordHash":"8M0ho&@4d5UIMt32*C4$sN67","gender":"FEMALE","avatarUrl":"https://s3.amazonaws.com/uifaces/faces/twitter/kvasnic/128.jpg","country":"Monaco","city":"Monrovia","zipCode":82148," |