当前位置: 首页>>代码示例>>Java>>正文


Java Tree类代码示例

本文整理汇总了Java中io.vavr.collection.Tree的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tree类属于io.vavr.collection包,在下文中一共展示了Tree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prettyPrint

import io.vavr.collection.Tree; //导入依赖的package包/类
private static <T> void prettyPrint(Tree.Node<T> treeNode, String indent, String indent2, StringBuilder s) {
    final String[] lines = treeNode.get().toString().split("\n");
    s.append(lines[0]);
    for (int i = 1; i < lines.length; i++) {
        s.append('\n')
         .append(indent2)
         .append(lines[i]);
    }
    for (List<Tree.Node<T>> it = treeNode.getChildren(); it.nonEmpty(); it = it.tail()) {
        final boolean isLast = it.tail().isEmpty();
        s.append('\n')
         .append(indent)
         .append(isLast ? "└──" : "├──");
        prettyPrint(it.head(), indent + (isLast ? "   " : "│  "), indent + (isLast ? "   " : "│  "), s);
    }
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:17,代码来源:PrettyPrinter.java

示例2: pp

import io.vavr.collection.Tree; //导入依赖的package包/类
public static <T> String pp(Tree<T> tree) {
    Objects.requireNonNull(tree, "tree is null");
    if (tree.isEmpty()) { return "▣"; }
    final StringBuilder builder = new StringBuilder();
    prettyPrint((Tree.Node<T>) tree, "", "", builder);
    return builder.toString();
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:8,代码来源:PrettyPrinter.java

示例3: box

import io.vavr.collection.Tree; //导入依赖的package包/类
public static <T> Box box(Tree<T> tree) {
    Objects.requireNonNull(tree, "tree is null");
    if (tree.isEmpty())
        return Box.of("▣");
    Tuple2<Box, Integer> x = nodeToBox((Node<T>) tree);
    return Box.col(Box.row(Box.of('┌'), Box.of('─', x._2-2, 1), Box.of('┐')), x._1);
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:8,代码来源:Boxes.java

示例4: processTree

import io.vavr.collection.Tree; //导入依赖的package包/类
private int processTree(Tree<?> tree, String parentLabel, int index) {
    Object value = tree.getValue();
    String label = "lbl" + index;
    labels.put(label, value.toString());
    if(parentLabel != null) {
        edges.add(parentLabel + " -> " + label);
    }
    for (Tree.Node<?> child : tree.getChildren()) {
        index = processTree(child, label, index + 1);
    }
    return index;
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:13,代码来源:DotFile.java

示例5: test

import io.vavr.collection.Tree; //导入依赖的package包/类
@Test
public void test() {
    final Tree<String> tree =
            Tree.of("Ann",
                    Tree.of("Mary",
                            Tree.of("John",
                                    Tree.of("Avila")),
                            Tree.of("Karen"),
                            Tree.of("Steven\nAbbot\nBraddock")),
                    Tree.of("Peter",
                            Tree.of("Paul\nPalucci"),
                            Tree.of("Anthony")));

    final DefaultMutableTreeNode t = io.vavr.render.swing.Tree.create(tree);
    @SuppressWarnings("rawtypes")
    final Enumeration v = t.preorderEnumeration();
    final StringBuilder builder = new StringBuilder();
    while (v.hasMoreElements())
        builder.append(v.nextElement()).append('\n');
    final String s = builder.toString();

    assertThat(s).isEqualTo("Ann\n" +
                            "Mary\n" +
                            "John\n" +
                            "Avila\n" +
                            "Karen\n" +
                            "Steven\n" +
                            "Abbot\n" +
                            "Braddock\n" +
                            "Peter\n" +
                            "Paul\n" +
                            "Palucci\n" +
                            "Anthony\n" +
                            "");
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:36,代码来源:TreeTest.java

示例6: next

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public <T> T next(final InstanceType<T> instanceType, final FixtureContract fixture) {
  return (T)new Tree.Node(
      fixture.create(instanceType.getNestedGenericType1()),
          List.empty()
          );
}
 
开发者ID:grzesiek-galezowski,项目名称:AutoFixtureGenerator,代码行数:8,代码来源:VavrNodeGenerator.java

示例7: nextEmpty

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public <T> T nextEmpty(final InstanceType<T> instanceType, final FixtureContract fixture) {
  return (T) new Tree.Node(
    fixture.createDummy(instanceType.getNestedGenericType1()),
    List.empty()
  );
}
 
开发者ID:grzesiek-galezowski,项目名称:AutoFixtureGenerator,代码行数:8,代码来源:VavrNodeGenerator.java

示例8: accepts

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public boolean accepts(Class<?> type) {
    return Tree.class.isAssignableFrom(type);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:5,代码来源:TreeContainerFactory.java

示例9: newContainerBuilderFor

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public ContainerBuilder<Tree<?>> newContainerBuilderFor(Class<?> type) {
    return new TreeContainerBuilder();
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:5,代码来源:TreeContainerFactory.java

示例10: add

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public ContainerBuilder<Tree<?>> add(Object it) {
    list.add(it);
    return this;
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:6,代码来源:TreeContainerFactory.java

示例11: build

import io.vavr.collection.Tree; //导入依赖的package包/类
@Override
public Tree<?> build() {
    return Tree.ofAll(list);
}
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:5,代码来源:TreeContainerFactory.java

示例12: findStartDatesAsTree

import io.vavr.collection.Tree; //导入依赖的package包/类
@SqlQuery("SELECT start_date FROM tasks")
Tree<LocalDate> findStartDatesAsTree();
 
开发者ID:dropwizard,项目名称:dropwizard-vavr,代码行数:3,代码来源:VavrDBIFactoryTest.java

示例13: create

import io.vavr.collection.Tree; //导入依赖的package包/类
public static DotFile create(Tree<?> tree) {
    return new DotFile(tree);
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:4,代码来源:DotFile.java

示例14: write

import io.vavr.collection.Tree; //导入依赖的package包/类
public static void write(Tree<?> tree, File file) throws IOException {
    FileWriter writer = new FileWriter(file);
    writer.write(create(tree).toString());
    writer.close();
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:6,代码来源:DotFile.java

示例15: DotFile

import io.vavr.collection.Tree; //导入依赖的package包/类
private DotFile(Tree<?> tree) {
    processTree(tree, null, 0);
}
 
开发者ID:vavr-io,项目名称:vavr-render,代码行数:4,代码来源:DotFile.java


注:本文中的io.vavr.collection.Tree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。