Add isless function for Edit

This commit is contained in:
Thomas A. Christensen II 2023-01-10 11:17:08 -06:00
parent 2ff4181dd8
commit 860ce56b34

View file

@ -17,6 +17,13 @@ end
Base.length(e::Edit) = length(_mutation(e)) Base.length(e::Edit) = length(_mutation(e))
Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x
Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h)) Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h))
function Base.isless(x::Edit, y::Edit)
if leftposition(x) == leftposition(y)
return length(x) < length(y)
end
return leftposition(x) < leftposition(y)
end
function Base.parse(::Type{T}, s::AbstractString) where {T<:Edit{Se,Sy}} where {Se,Sy} function Base.parse(::Type{T}, s::AbstractString) where {T<:Edit{Se,Sy}} where {Se,Sy}
return parse(T, String(s)) return parse(T, String(s))