Megrez::Grid // Fix wrong conditioning in expandGridByOneAt().

This commit is contained in:
ShikiSuen 2022-05-14 00:36:23 +08:00
parent c2dba51a50
commit 4d8cbb2db5
2 changed files with 6 additions and 5 deletions

View File

@ -46,7 +46,7 @@ extension Megrez {
if balanced { if balanced {
nodes.sort { nodes.sort {
$0.balancedScore > $1.balancedScore // NodeAnchor $0.balancedScore > $1.balancedScore
} }
} }

View File

@ -55,11 +55,12 @@ extension Megrez {
} }
public func expandGridByOneAt(location: Int) { public func expandGridByOneAt(location: Int) {
mutSpans.append(Span()) // abs
if location > 0, location < mutSpans.count { mutSpans.insert(Span(), at: abs(location))
for i in 0..<location { if location != 0, abs(location) != mutSpans.count {
for i in 0..<abs(location) {
// zaps overlapping spans // zaps overlapping spans
mutSpans[i].removeNodeOfLengthGreaterThan(location - i) mutSpans[i].removeNodeOfLengthGreaterThan(abs(location) - i)
} }
} }
} }