Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Класс Diff

Открытые члены

 getDiffHtml ($a, $b)
 
 getDiffScript (array $a, array $b)
 

Защищенные члены

 init ()
 
 longestCommonSubsequence (array $a, $lowerA, $upperA, array $b, $lowerB, $upperB)
 
 shortestMiddleSnake (array $a, $lowerA, $upperA, array $b, $lowerB, $upperB)
 
 createDiff (array $a, array $b)
 

Защищенные данные

 $upVector = array()
 
 $downVector = array()
 
 $modifiedA = array()
 
 $modifiedB = array()
 

Подробное описание

This Class implements the Difference Algorithm published in "An O(ND) Difference Algorithm and its Variations" by Eugene Myers Algorithmica Vol. 1 No. 2, 1986, p 251.

См. определение в файле diff.php строка 10

Методы

◆ createDiff()

createDiff ( array $a,
array $b )
protected

Function creates diff script. Should be called after longestCommonSubsequence().

Аргументы
array$aFirst array to be compared.
array$bSecond array to be compared.
Возвращает
array Array of edit steps to transform array $a to array $b.

См. определение в файле diff.php строка 287

◆ getDiffHtml()

getDiffHtml ( $a,
$b )

Function finds the difference between two versions of text and creates html output with highlighted edits to transform text from first to second version.

Аргументы
string$aFirst version of text to be compared.
string$bSecond version of text to be compared.
Возвращает
string

См. определение в файле diff.php строка 25

◆ getDiffScript()

getDiffScript ( array $a,
array $b )

Function compares two arrays and creates edit script, that is required to transform array $a to array $b

Аргументы
array$aFirst array to be compared.
array$bSecond array to be compared.
Возвращает
array Array of edit steps to transform array $a to array $b. Each step is an array with keys: startA - position in array $a startB - position in array $b deletedA - count of elements deleted from array $a insertedB - count of elements inserted from array $b.

См. определение в файле diff.php строка 89

◆ init()

init ( )
protected

Function initializes object's fields for usage in difference algorithm.

Возвращает
void

См. определение в файле diff.php строка 101

◆ longestCommonSubsequence()

longestCommonSubsequence ( array $a,
$lowerA,
$upperA,
array $b,
$lowerB,
$upperB )
protected

Function looks for longest common subsequence between two array

Аргументы
array$aFirst array to be compared.
int$lowerALower bound of the first array.
int$upperAUpper bound of the first array.
array$bSecond array to be compared.
int$lowerBLower bound of the second array.
int$upperBUpper bound of the second array.
Возвращает
void

См. определение в файле diff.php строка 120

◆ shortestMiddleSnake()

shortestMiddleSnake ( array $a,
$lowerA,
$upperA,
array $b,
$lowerB,
$upperB )
protected

Function looks for shortest middle snake between two arrays (see Meyer's work "An O(ND) Difference Algorithm and its Variations")

Аргументы
array$aFirst array to be compared.
int$lowerALower bound of the first array.
int$upperAUpper bound of the first array.
array$bSecond array to be compared.
int$lowerBLower bound of the second array.
int$upperBUpper bound of the second array.
Возвращает
array Array with keys 'x' and 'y', describing found shortest middle snake

См. определение в файле diff.php строка 179

Данные класса

◆ $downVector

$downVector = array()
protected

См. определение в файле diff.php строка 13

◆ $modifiedA

$modifiedA = array()
protected

См. определение в файле diff.php строка 14

◆ $modifiedB

$modifiedB = array()
protected

См. определение в файле diff.php строка 15

◆ $upVector

$upVector = array()
protected

См. определение в файле diff.php строка 12