File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
RaelizeLogic/Sources/RaelizeLogic/UseCase Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -81,13 +81,13 @@ extension WordListFileUseCaseType {
8181 /// - Returns: Array from the point containing the prefix specified by word to the point specified by candidatesSize
8282 func binarySearch( word: String , candidatesSize: Int , wordList: [ String ] ) -> [ String ] ? {
8383 var left = 0
84- var right = wordList. endIndex
84+ var right = wordList. count - 1
8585 while left <= right {
8686 let middle = ( left + right) / 2
8787
8888 if wordList [ middle] . lowercased ( ) . hasPrefix ( word) {
8989 var lastIndex = middle + candidatesSize
90- lastIndex = wordList. endIndex > lastIndex ? lastIndex : middle // check out of range
90+ lastIndex = wordList. count - 1 > lastIndex ? lastIndex : middle // check out of range
9191 return Array ( wordList [ middle... lastIndex] )
9292 } else if wordList [ middle] < word {
9393 left = middle + 1
You can’t perform that action at this time.
0 commit comments