mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-04-24 01:28:40 +02:00
feat: update ordering
This commit is contained in:
@@ -40,4 +40,17 @@ enum Element: Equatable, Comparable {
|
|||||||
photo.createdAt
|
photo.createdAt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func < (lhs: Element, rhs: Element) -> Bool {
|
||||||
|
switch (lhs, rhs) {
|
||||||
|
case let (.stroke(leftStroke), .stroke(rightStroke)):
|
||||||
|
leftStroke < rightStroke
|
||||||
|
case let (.photo(leftPhoto), .photo(rightPhoto)):
|
||||||
|
leftPhoto < rightPhoto
|
||||||
|
case let (.photo(photo), .stroke(stroke)):
|
||||||
|
photo.createdAt < stroke.value.createdAt
|
||||||
|
case let (.stroke(stroke), .photo(photo)):
|
||||||
|
stroke.value.createdAt < photo.createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ class RTree<T> where T: Equatable & Comparable {
|
|||||||
.sorted(by: <)
|
.sorted(by: <)
|
||||||
result = _merge(result, children)
|
result = _merge(result, children)
|
||||||
} else {
|
} else {
|
||||||
queue.append(contentsOf: node.children)
|
let nodes = node.children.sorted {
|
||||||
|
guard let first = $0.value, let second = $1.value else { return false }
|
||||||
|
return first < second
|
||||||
|
}
|
||||||
|
queue.append(contentsOf: nodes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user