MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / decode

Method decode

LabEnv/10Lab/MoveToFront.java:38–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37 // apply move-to-front decoding, reading from standard input and writing to standard output
38 public static void decode() {
39 char[] index2Char = init();
40 while (!BinaryStdIn.isEmpty()) {
41 int idx = BinaryStdIn.readChar();
42 char c = index2Char[idx];
43 for (int i = idx; i > 0; i--)
44 index2Char[i] = index2Char[i - 1];
45 index2Char[0] = c;
46
47 BinaryStdOut.write(c, 8);
48 }
49 BinaryStdOut.close();
50 }
51
52 // if args[0] is "-", apply move-to-front encoding
53 // if args[0] is "+", apply move-to-front decoding

Callers 1

mainMethod · 0.95

Calls 2

initMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected