Skip to content

A tree library for Java 8 with functional sensibilities.

Notifications You must be signed in to change notification settings

sinecycle/prune

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status Maven Central

A zero-nonsense tree library for Java 8

No dependencies. One top-level class. Depth-first and breadth-first node streaming, visiting, and searching. Prune off sections of the tree using predicate filters. ToString of a tree returns an ascii representation of the tree. Two nodes with the same data are equal. Two trees with the same structure and ordering of nodes with the same data are equal.

Usage

Tree<Integer> tree = node(1, 
                            node(2, 
                                node(5), node(5)), 
                            node(6, 
                                node(4), node(4)), 
                            node(2, 
                                node(3), node(3))).asTree();

Optional<Integer> firstIntegerGreaterThan4DepthFirst = tree.depthFirstSearch(val -> val > 4);
Optional<Integer> firstIntegerGreaterThan4BreadthFirst = tree.breadthFirstSearch(val -> val > 4);

assertTrue(firstIntegerGreaterThan4DepthFirst.isPresent());
assertTrue(firstIntegerGreaterThan4BreadthFirst.isPresent());

assertEquals((Integer) 5, firstIntegerGreaterThan4DepthFirst.get());
assertEquals((Integer) 6, firstIntegerGreaterThan4BreadthFirst.get());


System.out.println(tree);
1 -
    |
    |- 2
    |   |
    |   |- 5
    |   |
    |   |- 5
    |
    |- 6
    |   |
    |   |- 4
    |   |
    |   |- 4
    |
    |- 2
        |
        |- 3
        |
        |- 3

Install

<dependencies>
    
    <dependency>
        <groupId>com.github.rutledgepaulv</groupId>
        <artifactId>prune</artifactId>
        <version>1.3</version>
    </dependency>
            
</dependencies>

License

This project is licensed under MIT license.

About

A tree library for Java 8 with functional sensibilities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 97.3%
  • Shell 2.7%