From f2911f688b2b2280554b52875198a9b8cc064d5b Mon Sep 17 00:00:00 2001 From: Erik Welander Date: Tue, 22 May 2018 20:43:19 -0700 Subject: [PATCH] [Java] Change LinkedList to List for methods that do not mutate the list. Copying cr/103024338 --- .../neil/plaintext/diff_match_patch.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/java/src/name/fraser/neil/plaintext/diff_match_patch.java b/java/src/name/fraser/neil/plaintext/diff_match_patch.java index 77af9b1..72671e3 100644 --- a/java/src/name/fraser/neil/plaintext/diff_match_patch.java +++ b/java/src/name/fraser/neil/plaintext/diff_match_patch.java @@ -569,10 +569,10 @@ private String diff_linesToCharsMunge(String text, List lineArray, /** * Rehydrate the text in a diff from a string of line hashes to real lines of * text. - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @param lineArray List of unique strings. */ - protected void diff_charsToLines(LinkedList diffs, + protected void diff_charsToLines(List diffs, List lineArray) { StringBuilder text; for (Diff diff : diffs) { @@ -1304,11 +1304,11 @@ public void diff_cleanupMerge(LinkedList diffs) { * loc is a location in text1, compute and return the equivalent location in * text2. * e.g. "The cat" vs "The big cat", 1->1, 5->8 - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @param loc Location within text1. * @return Location within text2. */ - public int diff_xIndex(LinkedList diffs, int loc) { + public int diff_xIndex(List diffs, int loc) { int chars1 = 0; int chars2 = 0; int last_chars1 = 0; @@ -1341,10 +1341,10 @@ public int diff_xIndex(LinkedList diffs, int loc) { /** * Convert a Diff list into a pretty HTML report. - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @return HTML representation. */ - public String diff_prettyHtml(LinkedList diffs) { + public String diff_prettyHtml(List diffs) { StringBuilder html = new StringBuilder(); for (Diff aDiff : diffs) { String text = aDiff.text.replace("&", "&").replace("<", "<") @@ -1368,10 +1368,10 @@ public String diff_prettyHtml(LinkedList diffs) { /** * Compute and return the source text (all equalities and deletions). - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @return Source text. */ - public String diff_text1(LinkedList diffs) { + public String diff_text1(List diffs) { StringBuilder text = new StringBuilder(); for (Diff aDiff : diffs) { if (aDiff.operation != Operation.INSERT) { @@ -1383,10 +1383,10 @@ public String diff_text1(LinkedList diffs) { /** * Compute and return the destination text (all equalities and insertions). - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @return Destination text. */ - public String diff_text2(LinkedList diffs) { + public String diff_text2(List diffs) { StringBuilder text = new StringBuilder(); for (Diff aDiff : diffs) { if (aDiff.operation != Operation.DELETE) { @@ -1399,10 +1399,10 @@ public String diff_text2(LinkedList diffs) { /** * Compute the Levenshtein distance; the number of inserted, deleted or * substituted characters. - * @param diffs LinkedList of Diff objects. + * @param diffs List of Diff objects. * @return Number of changes. */ - public int diff_levenshtein(LinkedList diffs) { + public int diff_levenshtein(List diffs) { int levenshtein = 0; int insertions = 0; int deletions = 0; @@ -1431,10 +1431,10 @@ public int diff_levenshtein(LinkedList diffs) { * required to transform text1 into text2. * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. * Operations are tab-separated. Inserted text is escaped using %xx notation. - * @param diffs Array of Diff objects. + * @param diffs List of Diff objects. * @return Delta text. */ - public String diff_toDelta(LinkedList diffs) { + public String diff_toDelta(List diffs) { StringBuilder text = new StringBuilder(); for (Diff aDiff : diffs) { switch (aDiff.operation) {