WikiLambda
MediaWiki WikiLambda extension
Loading...
Searching...
No Matches
MediaWiki\Extension\WikiLambda\Diff\DiffMatrix Class Reference

Public Member Functions

 __construct (ZObjectDiffer $zObjectDiffer, array $oldArray, array $newArray)
 Creates a DiffMatrix object between an array of old values and an array of new values.
 
 getDiffOps (int $row, int $col)
 Get the set of DiffOps saved in the matrix by row and column indices.
 
 hasDiffOps (int $row, int $col)
 Whether the matrix position given by row and colum registers any diffs or not.
 
 getEditCountByRow ()
 Get the set of edit counts for every row.
 
 getEditCountByCol ()
 Get the set of edit counts for every column.
 
 getIndicesOfRemovedItems ()
 Return the indices of the rows (old values) that were most edited, which will be the ones most likely removed in the case that oldArray has more items than newArray.
 
 getIndicesOfAddedItems ()
 Return the indices of the cols (new values) that were most edited, which will be the ones most likely added in the case that oldArray has less items than newArray.
 
 getNormalizer (array $indices, int $index)
 Return integer that calculates the correct row or column index to access a particular matrix element depending on the items that have been removed or added in the diff.
 
 __toString ()
 Returns a string representing the matrix of edit counts.
 

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::__construct ( ZObjectDiffer $zObjectDiffer,
array $oldArray,
array $newArray )

Creates a DiffMatrix object between an array of old values and an array of new values.

This class also exposes utilities to operate on row and col edit counts and find items that have been deleted, added or changed positions.

Parameters
ZObjectDiffer$zObjectDifferinjected ZObjectDiffer to calculate diff between list items
array$oldArray
array$newArray

Member Function Documentation

◆ __toString()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::__toString ( )

Returns a string representing the matrix of edit counts.

Returns
string

◆ getDiffOps()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getDiffOps ( int $row,
int $col )

Get the set of DiffOps saved in the matrix by row and column indices.

Parameters
int$row
int$col
Returns
DiffOp

◆ getEditCountByCol()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getEditCountByCol ( )

Get the set of edit counts for every column.

Returns
int[]

◆ getEditCountByRow()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getEditCountByRow ( )

Get the set of edit counts for every row.

Returns
int[]

◆ getIndicesOfAddedItems()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getIndicesOfAddedItems ( )

Return the indices of the cols (new values) that were most edited, which will be the ones most likely added in the case that oldArray has less items than newArray.

The number of indices returned is always the difference between number of new items and number of old items.

Returns
int[]

◆ getIndicesOfRemovedItems()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getIndicesOfRemovedItems ( )

Return the indices of the rows (old values) that were most edited, which will be the ones most likely removed in the case that oldArray has more items than newArray.

The number of indices returned is always the difference between number of old items and number of new items.

Returns
int[]

◆ getNormalizer()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::getNormalizer ( array $indices,
int $index )

Return integer that calculates the correct row or column index to access a particular matrix element depending on the items that have been removed or added in the diff.

Parameters
int[]$indices
int$index
Returns
int

◆ hasDiffOps()

MediaWiki\Extension\WikiLambda\Diff\DiffMatrix::hasDiffOps ( int $row,
int $col )

Whether the matrix position given by row and colum registers any diffs or not.

Parameters
int$row
int$col
Returns
bool

The documentation for this class was generated from the following file: