Class Diff.FileData
- Enclosing class:
- Diff
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intNumber of elements (lines) in this file.private boolean[]Array, indexed by real origin-1 line number, containing true for a line that is an insertion or a deletion.private final int[]Vector, indexed by line number, containing an equivalence code for each line.private intTotal number of nondiscarded lines.private final int[]Vector mapping virtual line numbers (not counting discarded lines) to real ones (counting those lines).private final int[]Vector, like the previous one except that the elements for discarded lines have been squeezed out. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidclear()Allocate changed array for the results of comparison.private voiddiscard(byte[] discards) Actually discard the lines.private byte[]discardable(int... counts) Mark to be discarded each line that matches no line of another file.(package private) voidDiscard lines that have no matches in another file.(package private) int[]Return equiv_count[I] as the number of lines in this file that fall in equivalence class I.private voidfilterDiscards(byte[] discards) Don't really discard the provisional lines except when they occur in a run of discardables, with nonprovisionals at the beginning and end.(package private) voidAdjust inserts/deletes of blank lines to join changes as much as possible.
-
Field Details
-
bufferedLines
Number of elements (lines) in this file. -
equivs
Vector, indexed by line number, containing an equivalence code for each line. It is this vector that is actually compared with that of another file to generate differences. -
undiscarded
Vector, like the previous one except that the elements for discarded lines have been squeezed out. -
realindexes
Vector mapping virtual line numbers (not counting discarded lines) to real ones (counting those lines). Both are origin-0. -
nondiscardedLines
Total number of nondiscarded lines. -
changedFlag
Array, indexed by real origin-1 line number, containing true for a line that is an insertion or a deletion. The results of comparison are stored here.
-
-
Constructor Details
-
FileData
FileData(int length) -
FileData
-
-
Method Details
-
clear
void clear()Allocate changed array for the results of comparison. -
equivCount
int[] equivCount()Return equiv_count[I] as the number of lines in this file that fall in equivalence class I.- Returns:
- the array of equivalence class counts.
-
discardConfusingLines
Discard lines that have no matches in another file.A line which is discarded will not be considered by the actual comparison algorithm; it will be as if that line were not in the file. The file's `realindexes' table maps virtual line numbers (which don't count the discarded lines) into real line numbers; this is how the actual comparison algorithm produces results that are comprehensible when the discarded lines are counted.
When we discard a line, we also mark it as a deletion or insertion so that it will be printed in the output.
- Parameters:
f- the other file
-
discardable
Mark to be discarded each line that matches no line of another file. If a line matches many lines, mark it as provisionally discardable.- Parameters:
counts- The count of each equivalence number for the other file.- Returns:
- 0=nondiscardable, 1=discardable or 2=provisionally discardable for each line
- See Also:
-
filterDiscards
Don't really discard the provisional lines except when they occur in a run of discardables, with nonprovisionals at the beginning and end.- Parameters:
discards- discards
-
discard
Actually discard the lines.- Parameters:
discards- flags lines to be discarded
-
shiftBoundaries
Adjust inserts/deletes of blank lines to join changes as much as possible.We do something when a run of changed lines include a blank line at one end and have an excluded blank line at the other. We are free to choose which blank line is included. `compareseq' always chooses the one at the beginning, but usually it is cleaner to consider the following blank line to be the "change". The only exception is if the preceding blank line would join this change to other changes.
- Parameters:
f- the file being compared against
-