simplify
parent
9946cd4f34
commit
b19fd3bfb1
|
@ -1,14 +1,13 @@
|
|||
# String with Length
|
||||
# This allows to compute length once and only once
|
||||
struct StringWithLength{T} <: AbstractString
|
||||
struct StringWithLength{T<:AbstractString} <: AbstractString
|
||||
s::T
|
||||
l::Int
|
||||
end
|
||||
string_with_length(s::AbstractString) = StringWithLength(s, length(s))
|
||||
string_with_length(s::StringWithLength) = s
|
||||
Base.length(s::StringWithLength) = s.l
|
||||
Base.iterate(s::StringWithLength) = iterate(s.s)
|
||||
Base.iterate(s::StringWithLength, i::Integer) = iterate(s.s, i)
|
||||
Base.iterate(s::StringWithLength, i::Integer = firstindex(s.s)) = iterate(s.s, i)
|
||||
Base.isequal(s1::StringWithLength, s2::AbstractString) = isequal(s.s1, s2)
|
||||
Base.isequal(s1::AbstractString, s2::StringWithLength) = isequal(s1, s2.s)
|
||||
Base.nextind(s::StringWithLength, i::Int, n::Int = 1) = nextind(s.s, i, n)
|
||||
|
@ -42,8 +41,6 @@ function remove_prefix(s1::AbstractString, s2::AbstractString, lim::Integer = -1
|
|||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# Return start of commn substring in s1, start of common substring in s2, and length of substring
|
||||
# Indexes refer to character number, not index
|
||||
function longest_common_substring(s1::AbstractString, s2::AbstractString, len1::Integer, len2::Integer)
|
||||
|
|
Loading…
Reference in New Issue