[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:
Miwa / Ensan
2024-01-13 01:52:36 +09:00
committed by GitHub
parent f2c5c3c58d
commit 365e32e7bf

View File

@@ -79,20 +79,18 @@ struct LOUDS: Sendable {
// startIndexbitsindex `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
//
// parentNodeIndex0`k`