mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
[Refactoring] 二分探索を単純化 (#31)
* simplify calculation * cleanup * add code fro debug * fix bug * cleanup * cleanup * add binary search * cleanup binary search * cleanup binary search * cleanup init * cleanup init * debugging: flatten indices * flatten indices * calc range with SIMD2 * add assertion * Simplify binary search * cleanup
This commit is contained in:
@@ -79,20 +79,18 @@ struct LOUDS: Sendable {
|
||||
// 探しているのは、startIndexが含まれるbitsのindex `i`
|
||||
var left = parentNodeIndex >> Self.uExp
|
||||
var right = self.rankLarge.endIndex - 1
|
||||
var i = self.rankLarge.endIndex
|
||||
while left <= right {
|
||||
let mid = (left + right) / 2
|
||||
if self.rankLarge[mid] >= parentNodeIndex {
|
||||
i = mid
|
||||
right = mid - 1
|
||||
} else {
|
||||
left = mid + 1
|
||||
}
|
||||
}
|
||||
guard i != self.rankLarge.endIndex else {
|
||||
guard left != self.rankLarge.endIndex else {
|
||||
return 0 ..< 0
|
||||
}
|
||||
i -= 1
|
||||
let i = left - 1
|
||||
return self.bits.withUnsafeBufferPointer {(buffer: UnsafeBufferPointer<Unit>) -> Range<Int> in
|
||||
// 探索パート②
|
||||
// 目標はparentNodeIndex番目の0の位置である`k`の発見
|
||||
|
||||
Reference in New Issue
Block a user