當前位置: 首頁>>代碼示例>>Java>>正文


Java PrettyPrinter類代碼示例

本文整理匯總了Java中com.googlecode.concurrenttrees.common.PrettyPrinter的典型用法代碼示例。如果您正苦於以下問題:Java PrettyPrinter類的具體用法?Java PrettyPrinter怎麽用?Java PrettyPrinter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PrettyPrinter類屬於com.googlecode.concurrenttrees.common包,在下文中一共展示了PrettyPrinter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) {
    ReversedRadixTree<Integer> tree = new ConcurrentReversedRadixTree<Integer>(new DefaultCharArrayNodeFactory());

    tree.put("TEST", 1);
    tree.put("TOAST", 2);
    tree.put("TEAM", 3);

    System.out.println("Tree structure:");
    // PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees...
    PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);

    System.out.println();
    System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST"));
    System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST"));
    System.out.println();
    System.out.println("Keys ending with 'ST': " + Iterables.toString(tree.getKeysEndingWith("ST")));
    System.out.println("Keys ending with 'M': " + Iterables.toString(tree.getKeysEndingWith("M")));
    System.out.println();
    System.out.println("Values for keys ending with 'ST': " + Iterables.toString(tree.getValuesForKeysEndingWith("ST")));
    System.out.println("Key-Value pairs for keys ending with 'ST': " + Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("ST")));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:22,代碼來源:ReversedRadixTreeUsage.java

示例2: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) {
    InvertedRadixTree<Integer> tree = new ConcurrentInvertedRadixTree<Integer>(new DefaultCharArrayNodeFactory());

    tree.put("TEST", 1);
    tree.put("TOAST", 2);
    tree.put("TEAM", 3);

    System.out.println("Tree structure:");
    // PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees...
    PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);

    System.out.println();
    System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST"));
    System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST"));
    System.out.println();
    System.out.println("Keys contained in 'MY TEAM LIKES TOAST': " + Iterables.toString(tree.getKeysContainedIn("MY TEAM LIKES TOAST")));
    System.out.println("Keys contained in 'MY TEAM LIKES TOASTERS': " + Iterables.toString(tree.getKeysContainedIn("MY TEAM LIKES TOASTERS")));
    System.out.println("Values for keys contained in 'MY TEAM LIKES TOAST': " + Iterables.toString(tree.getValuesForKeysContainedIn("MY TEAM LIKES TOAST")));
    System.out.println("Key-value pairs for keys contained in 'MY TEAM LIKES TOAST': " + Iterables.toString(tree.getKeyValuePairsForKeysContainedIn("MY TEAM LIKES TOAST")));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:21,代碼來源:InvertedRadixTreeUsage.java

示例3: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) {
    RadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(new DefaultCharArrayNodeFactory());

    tree.put("TEST", 1);
    tree.put("TOAST", 2);
    tree.put("TEAM", 3);

    System.out.println("Tree structure:");
    // PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees...
    PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);

    System.out.println();
    System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST"));
    System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST"));
    System.out.println();
    System.out.println("Keys starting with 'T': " + Iterables.toString(tree.getKeysStartingWith("T")));
    System.out.println("Keys starting with 'TE': " + Iterables.toString(tree.getKeysStartingWith("TE")));
    System.out.println();
    System.out.println("Values for keys starting with 'TE': " + Iterables.toString(tree.getValuesForKeysStartingWith("TE")));
    System.out.println("Key-Value pairs for keys starting with 'TE': " + Iterables.toString(tree.getKeyValuePairsForKeysStartingWith("TE")));
    System.out.println();
    System.out.println("Keys closest to 'TEMPLE': " + Iterables.toString(tree.getClosestKeys("TEMPLE")));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:24,代碼來源:RadixTreeUsage.java

示例4: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    ConcurrentSuffixTree<String> tree = new ConcurrentSuffixTree<String>(new DefaultCharSequenceNodeFactory());
    for (String file : files) {
        String manuscript = IOUtil.loadTextFileFromClasspath(file, true, true, true); // true = convert to lowercase
        String manuscriptName = file.replaceAll("/.*/.*/", "").replace(".txt", "");
        tree.put(manuscript, manuscriptName);
        System.out.println("Added " + manuscriptName);
    }
    System.out.println("Built Suffix Tree. Estimating size on disk...");
    Thread.sleep(30000);
    DummyAppendable dummyAppendable = new DummyAppendable();
    PrettyPrinter.prettyPrint(tree, dummyAppendable);
    System.out.println("Done. Size on disk estimate:");
    System.out.println("Lines: " + dummyAppendable.lineCount);
    System.out.println("Characters: " + dummyAppendable.charCount);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:17,代碼來源:BuildShakespeareTragediesSuffixTree.java

示例5: testPut_SplitAndMove

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testPut_SplitAndMove() {
    ConcurrentRadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(getNodeFactory());
    tree.put("TEST", 1);
    tree.put("TEAM", 2);
    tree.put("TOAST", 3);

    String expected =
            "○\n" +
            "└── ○ T\n" +             // implicit node added automatically
            "    ├── ○ E\n" +         // implicit node added automatically
            "    │   ├── ○ AM (2)\n" +
            "    │   └── ○ ST (1)\n" +
            "    └── ○ OAST (3)\n";
    String actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:18,代碼來源:ConcurrentRadixTreeTest.java

示例6: testRemove_LastRemainingKey

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testRemove_LastRemainingKey() {
    ConcurrentRadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(getNodeFactory());
    tree.put("FOO", 1);

    //    ○
    //    └── ○ FOO (1)

    String expected, actual;
    expected =
            "○\n" +
            "└── ○ FOO (1)\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);

    boolean removed = tree.remove("FOO");
    assertTrue(removed);

    //    ○                 // FOO removed, which involved recreating the root with no remaining edges

    expected =
            "○\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:26,代碼來源:ConcurrentRadixTreeTest.java

示例7: testRemove_NoSuchKey

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testRemove_NoSuchKey() {
    ConcurrentRadixTree<Integer> tree = new ConcurrentRadixTree<Integer>(getNodeFactory());
    tree.put("FOO", 1);
    tree.put("BAR", 2);

    String expected, actual;
    expected =
            "○\n" +
            "├── ○ BAR (2)\n" +
            "└── ○ FOO (1)\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);

    boolean removed = tree.remove("BAZ");
    assertFalse(removed);

    expected =
            "○\n" +                     // we expect no change
            "├── ○ BAR (2)\n" +
            "└── ○ FOO (1)\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:25,代碼來源:ConcurrentRadixTreeTest.java

示例8: testPut_ReplaceValue

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testPut_ReplaceValue() throws Exception {
    ConcurrentSuffixTree<Integer> tree = newConcurrentSuffixTreeForUnitTests();
    tree.put("BANANA", 1);
    tree.put("BANANA", 2);

    String expected =
            "○\n" +
            "├── ○ A ([BANANA])\n" +
            "│   └── ○ NA ([BANANA])\n" +
            "│       └── ○ NA ([BANANA])\n" +
            "├── ○ BANANA ([BANANA])\n" +
            "└── ○ NA ([BANANA])\n" +
            "    └── ○ NA ([BANANA])\n";
    String actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
    assertEquals(Integer.valueOf(2), tree.getValueForExactKey("BANANA"));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:19,代碼來源:ConcurrentSuffixTreeTest.java

示例9: testPutIfAbsent

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testPutIfAbsent() throws Exception {
    ConcurrentSuffixTree<Integer> tree = newConcurrentSuffixTreeForUnitTests();
    tree.putIfAbsent("BANANA", 1);
    tree.putIfAbsent("BANANA", 2); // should be ignored

    String expected =
            "○\n" +
            "├── ○ A ([BANANA])\n" +
            "│   └── ○ NA ([BANANA])\n" +
            "│       └── ○ NA ([BANANA])\n" +
            "├── ○ BANANA ([BANANA])\n" +
            "└── ○ NA ([BANANA])\n" +
            "    └── ○ NA ([BANANA])\n";
    String actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
    assertEquals(Integer.valueOf(1), tree.getValueForExactKey("BANANA"));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:19,代碼來源:ConcurrentSuffixTreeTest.java

示例10: testPut

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testPut() throws Exception {
    ConcurrentReversedRadixTree<Integer> tree = new ConcurrentReversedRadixTree<Integer>(getNodeFactory());
    tree.put("TEST", 1);
    tree.put("TEAM", 2);
    tree.put("TOAST", 3);

    String expected =
            "○\n" +
            "├── ○ MAET (2)\n" +
            "└── ○ TS\n" +
            "    ├── ○ AOT (3)\n" +
            "    └── ○ ET (1)\n";
    String actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:17,代碼來源:ConcurrentReversedRadixTreeTest.java

示例11: testPutIfAbsent

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testPutIfAbsent() throws Exception {
    ConcurrentReversedRadixTree<Integer> tree = new ConcurrentReversedRadixTree<Integer>(getNodeFactory());
    tree.putIfAbsent("TEST", 1);
    tree.putIfAbsent("TEAM", 2);
    tree.putIfAbsent("TOAST", 3);
    tree.putIfAbsent("TEAM", 4); // should be ignored

    String expected =
            "○\n" +
            "├── ○ MAET (2)\n" +
            "└── ○ TS\n" +
            "    ├── ○ AOT (3)\n" +
            "    └── ○ ET (1)\n";
    String actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:18,代碼來源:ConcurrentReversedRadixTreeTest.java

示例12: testRemove

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
@Test
public void testRemove() throws Exception {
    ConcurrentReversedRadixTree<Integer> tree = new ConcurrentReversedRadixTree<Integer>(getNodeFactory());
    tree.put("TEST", 1);
    tree.put("TEAM", 2);
    tree.put("TOAST", 3);

    String expected, actual;
    expected =
            "○\n" +
            "├── ○ MAET (2)\n" +
            "└── ○ TS\n" +
            "    ├── ○ AOT (3)\n" +
            "    └── ○ ET (1)\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);

    tree.remove("TEST");

    expected =
            "○\n" +
            "├── ○ MAET (2)\n" +
            "└── ○ TSAOT (3)\n";
    actual = PrettyPrinter.prettyPrint(tree);
    assertEquals(expected, actual);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:27,代碼來源:ConcurrentReversedRadixTreeTest.java

示例13: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) {
    // A file system to store Brochure objects...
    InMemoryFileSystem<Brochure> fileSystem = new ConcurrentRadixTreeInMemoryFileSystem<Brochure>();

    Brochure fordFocusBrochure = new Brochure("Marketing stuff for Ford Focus");
    Brochure fordF150Brochure = new Brochure("Marketing stuff for Ford F150");
    Brochure hondaCivicBrochure = new Brochure("Marketing stuff for Honda Civic");

    fileSystem.addFile("/brochures/ford/", "ford_focus_brochure.txt", fordFocusBrochure);
    fileSystem.addFile("/brochures/ford/", "ford_f150_brochure.txt", fordF150Brochure);
    fileSystem.addFile("/brochures/honda/", "honda_civic_brochure.txt", hondaCivicBrochure);

    System.out.println("Internal file system representation (not public):-");
    PrettyPrinter.prettyPrint((PrettyPrintable) fileSystem, System.out);

    System.out.println();
    System.out.println("Retrieve Ford brochure names in directory: " + fileSystem.getFileNamesInDirectory("/brochures/ford/"));
    System.out.println("Retrieve Honda brochure names in directory: " + fileSystem.getFileNamesInDirectory("/brochures/honda/"));
    System.out.println("Retrieve All brochure names recursively: " + fileSystem.getFileNamesInDirectoryRecursive("/brochures/"));

    System.out.println();
    Brochure fordF150BrochureRetrieved = fileSystem.getFile("/brochures/ford/", "ford_f150_brochure.txt");
    System.out.println("Retrieve Ford F150 brochure contents using exact file name: " + fordF150BrochureRetrieved);

    System.out.println();
    System.out.println("Retrieve all Ford brochure contents in directory:-");
    Collection<Brochure> fordBrochuresRetrieved = fileSystem.getFilesInDirectory("/brochures/ford/");
    for (Brochure fordBrochure : fordBrochuresRetrieved) {
        System.out.println(fordBrochure);
    }

    System.out.println();
    System.out.println("Retrieve contents from entire file system recursively:-");
    Collection<Brochure> allFiles = fileSystem.getFilesInDirectoryRecursive("/");
    for (Brochure file : allFiles) {
        System.out.println(file);
    }
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:39,代碼來源:InMemoryFileSystemUsage.java

示例14: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) {
    System.out.println("Suffixes for 'TEST': " + Iterables.toString(CharSequences.generateSuffixes("TEST")));
    System.out.println("Suffixes for 'TOAST': " + Iterables.toString(CharSequences.generateSuffixes("TOAST")));
    System.out.println("Suffixes for 'TEAM': " + Iterables.toString(CharSequences.generateSuffixes("TEAM")));

    SuffixTree<Integer> tree = new ConcurrentSuffixTree<Integer>(new DefaultCharArrayNodeFactory());

    tree.put("TEST", 1);
    tree.put("TOAST", 2);
    tree.put("TEAM", 3);

    System.out.println();
    System.out.println("Tree structure:");
    // PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees...
    PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out);

    System.out.println();
    System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST"));
    System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST"));
    System.out.println();
    System.out.println("Keys ending with 'ST': " + Iterables.toString(tree.getKeysEndingWith("ST")));
    System.out.println("Keys ending with 'M': " + Iterables.toString(tree.getKeysEndingWith("M")));
    System.out.println("Values for keys ending with 'ST': " + Iterables.toString(tree.getValuesForKeysEndingWith("ST")));
    System.out.println("Key-Value pairs for keys ending with 'ST': " + Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("ST")));
    System.out.println();
    System.out.println("Keys containing 'TE': " + Iterables.toString(tree.getKeysContaining("TE")));
    System.out.println("Keys containing 'A': " + Iterables.toString(tree.getKeysContaining("A")));
    System.out.println("Values for keys containing 'A': " + Iterables.toString(tree.getValuesForKeysContaining("A")));
    System.out.println("Key-Value pairs for keys containing 'A': " + Iterables.toString(tree.getKeyValuePairsForKeysContaining("A")));
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:31,代碼來源:SuffixTreeUsage.java

示例15: main

import com.googlecode.concurrenttrees.common.PrettyPrinter; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    ConcurrentSuffixTree<String> tree = new ConcurrentSuffixTree<String>(new DefaultCharSequenceNodeFactory());
    for (String file : files) {
        String manuscript = IOUtil.loadTextFileFromClasspath(file, true, true, true); // true = convert to lowercase
        String manuscriptName = file.replaceAll("/.*/.*/", "").replace(".txt", "");
        tree.put(manuscript, manuscriptName);
        System.out.println("Added " + manuscriptName);
    }
    System.out.println("Built Suffix Tree. Estimating size on disk...");
    DummyAppendable dummyAppendable = new DummyAppendable();
    PrettyPrinter.prettyPrint(tree, dummyAppendable);
    System.out.println("Done. Size on disk estimate:");
    System.out.println("Lines: " + dummyAppendable.lineCount);
    System.out.println("Characters: " + dummyAppendable.charCount);
}
 
開發者ID:npgall,項目名稱:concurrent-trees,代碼行數:16,代碼來源:BuildShakespeareSinglePlaySuffixTree.java


注:本文中的com.googlecode.concurrenttrees.common.PrettyPrinter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。