MCPcopy
hub / github.com/kevin-wayne/algs4 / main

Method main

src/main/java/edu/princeton/cs/algs4/SuffixArray.java:197–219  ·  view source on GitHub ↗

Unit tests the SuffixArray data type. @param args the command-line arguments

(String[] args)

Source from the content-addressed store, hash-verified

195 * @param args the command-line arguments
196 */
197 public static void main(String[] args) {
198 String s = StdIn.readAll().replaceAll("\\s+", " ").trim();
199 SuffixArray suffix = new SuffixArray(s);
200
201 // StdOut.println("rank(" + args[0] + ") = " + suffix.rank(args[0]));
202
203 StdOut.println(" i ind lcp rnk select");
204 StdOut.println("---------------------------");
205
206 for (int i = 0; i < s.length(); i++) {
207 int index = suffix.index(i);
208 String ith = "\"" + s.substring(index, Math.min(index + 50, s.length())) + "\"";
209 assert s.substring(index).equals(suffix.select(i));
210 int rank = suffix.rank(s.substring(index));
211 if (i == 0) {
212 StdOut.printf("%3d %3d %3s %3d %s\n", i, index, "-", rank, ith);
213 }
214 else {
215 int lcp = suffix.lcp(i);
216 StdOut.printf("%3d %3d %3d %3d %s\n", i, index, lcp, rank, ith);
217 }
218 }
219 }
220
221}
222

Callers

nothing calls this directly

Calls 10

readAllMethod · 0.95
printlnMethod · 0.95
indexMethod · 0.95
selectMethod · 0.95
rankMethod · 0.95
printfMethod · 0.95
lcpMethod · 0.95
lengthMethod · 0.45
minMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected