Megrez::Grid // Fix wrong conditioning in expandGridByOneAt().
This commit is contained in:
parent
c2dba51a50
commit
4d8cbb2db5
|
@ -46,7 +46,7 @@ extension Megrez {
|
|||
|
||||
if balanced {
|
||||
nodes.sort {
|
||||
$0.balancedScore > $1.balancedScore // 排序規則已經在 NodeAnchor 內定義了。
|
||||
$0.balancedScore > $1.balancedScore
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,12 @@ extension Megrez {
|
|||
}
|
||||
|
||||
public func expandGridByOneAt(location: Int) {
|
||||
mutSpans.append(Span())
|
||||
if location > 0, location < mutSpans.count {
|
||||
for i in 0..<location {
|
||||
// 這裡加入 abs 完全是一個防呆設計
|
||||
mutSpans.insert(Span(), at: abs(location))
|
||||
if location != 0, abs(location) != mutSpans.count {
|
||||
for i in 0..<abs(location) {
|
||||
// zaps overlapping spans
|
||||
mutSpans[i].removeNodeOfLengthGreaterThan(location - i)
|
||||
mutSpans[i].removeNodeOfLengthGreaterThan(abs(location) - i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue