This commit is contained in:
Ingy döt Net 2013-06-05 21:47:54 +00:00
parent 1f1ad49427
commit 6f050a029e
2496 changed files with 37609 additions and 3031 deletions

View file

@ -38,7 +38,7 @@ public class LZW {
dictionary.put(i, "" + (char)i);
String w = "" + (char)(int)compressed.remove(0);
String result = w;
StringBuffer result = new StringBuffer(w);
for (int k : compressed) {
String entry;
if (dictionary.containsKey(k))
@ -48,14 +48,14 @@ public class LZW {
else
throw new IllegalArgumentException("Bad compressed k: " + k);
result += entry;
result.append(entry);
// Add w+entry[0] to the dictionary.
dictionary.put(dictSize++, w + entry.charAt(0));
w = entry;
}
return result;
return result.toString();
}
public static void main(String[] args) {