当前位置: 首页>>代码示例>>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;未经允许,请勿转载。