prune

A zero-nonsense tree library for Java 8.

License

License

MIT
GroupId

GroupId

com.github.rutledgepaulv
ArtifactId

ArtifactId

prune
Last Version

Last Version

1.3
Release Date

Release Date

Type

Type

jar
Description

Description

prune
A zero-nonsense tree library for Java 8.
Project URL

Project URL

https://github.com/rutledgepaulv/prune
Source Code Management

Source Code Management

https://github.com/rutledgepaulv/prune

Download prune

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.rutledgepaulv/prune/ -->
<dependency>
    <groupId>com.github.rutledgepaulv</groupId>
    <artifactId>prune</artifactId>
    <version>1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.rutledgepaulv/prune/
implementation 'com.github.rutledgepaulv:prune:1.3'
// https://jarcasting.com/artifacts/com.github.rutledgepaulv/prune/
implementation ("com.github.rutledgepaulv:prune:1.3")
'com.github.rutledgepaulv:prune:jar:1.3'
<dependency org="com.github.rutledgepaulv" name="prune" rev="1.3">
  <artifact name="prune" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.rutledgepaulv', module='prune', version='1.3')
)
libraryDependencies += "com.github.rutledgepaulv" % "prune" % "1.3"
[com.github.rutledgepaulv/prune "1.3"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

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.

Versions

Version
1.3
1.2
1.1
1.0