object Algorithms
- Alphabetic
- By Inheritance
- Algorithms
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def commonSubstringIndicesToDiff(a: String, b: String, initialCommonSubstringIndices: List[(Int, Int, Int)]): Seq[Diff[Char]]
Convert a list of common substring indices into a diff.
Convert a list of common substring indices into a diff.
- returns
a diff of
a
andb
based oninitialCommonSubstringIndices
. IfinitialCommonSubstringIndices
contains no empty runs, the result will not contain anInsert(_)
followed by aDelete(_)
, i.e. in difference regions it puts characters froma
before those fromb
. IfinitialCommonSubstringIndices
does not correspond to a common subsequence ofa
andb
, hilarity may ensue.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def findMiddle(a: String, b: String, zero: Int, vForward: Array[Int], vReverse: Array[Int], i: Int, n: Int, j: Int, m: Int): (Int, (Int, Int, Int))
Find a
(dist, (xlo, xhi, ylo))
such thatdist
is the LCS edit distance betweena.substring(i, n)
andb.substring(j, m)
, and such thata(i) == b(i - xlo + ylo)
for alli
in(xlo until xhi)
.Find a
(dist, (xlo, xhi, ylo))
such thatdist
is the LCS edit distance betweena.substring(i, n)
andb.substring(j, m)
, and such thata(i) == b(i - xlo + ylo)
for alli
in(xlo until xhi)
.If
0 <= i <= n <= a.size
and0 <= j <= m <= b.size
don't both hold, hilarity may ensue.- a
the observed/old sequence
- b
the expected/new sequence
- zero
an index into
vForward
andvReverse
such that((zero - (a.size + b.size)) to (zero + (a.size + b.size)))
is a range of valid (in-bounds) indices intovForward
andvReverse
- vForward
an array, some entries of which will be overwritten
- vReverse
an array, some entries of which will be overwritten
- i
the start (inclusive) of the substring of
a
to search in- n
the end (exclusive) of the substring of
a
to search in- j
the start (inclusive) of the substring of
b
to search in- m
the end (exclusive) of the substring of
b
to search in- returns
see description
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lcsSubstringIndices(a: String, b: String): List[(Int, Int, Int)]
- returns
a list of substring indices
(xlo, xhi, ylo)
which together make up a (the) longest common subsequence betweena
andb
. The substring index triples are such thatlcsRuns(a, b).forall { case (xlo, xhi, ylo) => (xlo until xhi).forall(i => a(i) == b(i - xlo + ylo)) }
furthermore
lcsRuns(a, b).flatMap(t => Seq(t._1, t._2))
is sorted, and so islcsRuns(a, b).map(_._3)
- def longestCommonSubsequenceEdits(a: String, b: String): Seq[Diff[Char]]
See "An
O(ND)
Difference Algorithm and Its Variations" by Eugene W.See "An
O(ND)
Difference Algorithm and Its Variations" by Eugene W. Myers at http://xmailserver.org/diff2.pdf; this implements the linear space recursive bidirectional search.- returns
a char-by-char diff describing how to turn
a
intob
. Specifically,a == longestCommonSubsequenceEdits(a, b).collect { case Common(c) => c case Delete(c) => c }.mkString
and
b == longestCommonSubsequenceEdits(a, b).collect { case Common(c) => c case Insert(c) => c }.mkString
and
// this is the longest common subsequence of a and b: longestCommonSubsequenceEdits(a, b).collect { case Common(c) => c }
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def recurseAroundTheMiddle(a: String, b: String, zero: Int, vForward: Array[Int], vReverse: Array[Int], i: Int, n: Int, j: Int, m: Int, commonSubstringIndices: List[(Int, Int, Int)] = Nil): List[(Int, Int, Int)]
Use findMiddle to find a common substring with (approximately) half the differences before it and half the differences after it, such that the common substring is part of the longest common subsequence.
Use findMiddle to find a common substring with (approximately) half the differences before it and half the differences after it, such that the common substring is part of the longest common subsequence. This substring may be empty. Then recursively solve the two subproblems on each side of the substring.
The parameters are the same as findMiddle with one exception.
- commonSubstringIndices
return value accumulator, initially Nil
- returns
a list of common substring indices making up the longest common subsequence.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated