Watch
2
0
Fork
You've already forked abstand
0
Interval trees.
  • Java 97.9%
  • Shell 2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
rm d87ea84067
Some checks are pending
main-RHEL10-x86_64-jdk25 / Build (push) Waiting to run
main-RHEL10-x86_64-jdk26 / Build (push) Waiting to run
main-RHEL9-x86_64-jdk25 / Build (push) Waiting to run
main-RHEL9-x86_64-jdk26 / Build (push) Waiting to run
Merge pull request 'Update dependency ch.qos.logback:logback-classic to v1.6.1' (#4) from renovate/logback-monorepo into main
Reviewed-on: https://forge.int.arc7.info/io7m-com/abstand/pulls/4
2026-07-31 15:33:30 +00:00
.forgejo Update workflows. 2026-07-31 16:27:28 +01:00
com.io7m.abstand.core Fix checkstyle issues. 2025-04-26 18:48:40 +00:00
com.io7m.abstand.generation Begin next development iteration. 2024-06-02 21:37:28 +00:00
com.io7m.abstand.tests Begin next development iteration. 2024-06-02 21:37:28 +00:00
references Initial version. 2024-02-27 22:19:37 +00:00
src/site/resources Update site metadata. 2025-08-09 15:06:34 +00:00
.gitignore Update .gitignore. 2024-05-07 16:01:39 +00:00
checkstyle-filter.xml Initial version. 2024-02-27 22:19:37 +00:00
checkstyle-suppressions-1.0.dtd Initial version. 2024-02-27 22:19:37 +00:00
doc7m-books.json Add empty books configuration. 2026-07-31 15:46:10 +01:00
pom.xml Update dependency ch.qos.logback:logback-classic to v1.6.1 2026-07-31 15:30:17 +00:00
README-CHANGES.xml Mark release 1.1.0 2024-06-02 21:37:10 +00:00
README-LICENSE.txt Initial version. 2024-02-27 22:19:37 +00:00
README.in Migrate project. 2026-06-27 10:04:17 +01:00
README.md Migrate project. 2026-06-27 10:04:17 +01:00

abstand

Maven Central Maven Central (snapshot) Java Version

com.io7m.abstand

Abstand

A simple, correct, efficient interval tree implementation.

Motivation

At the time of writing, no interval tree implementations exist for Java that have all of the following properties:

  • Simple, readable, and well-commented.
  • Not part of an existing massive, poor-quality library such as Guava.
  • Heavily tested with an exhaustive test suite.
  • Liberally licensed.
  • Published to Maven Central.
  • JPMS-ready.
  • OSGi-ready.

The abstand package provides a generic interval tree implementation based on an AVL tree that aims to meet all of the above requirements.

Usage

Implementations of the IntervalTreeType are implementations of Set that also allow for overlapping queries:

var t = IntervalTree.<Long>create();
t.add(IntervalL.of(20, 30));
t.add(IntervalL.of(25, 30));

var o = t.overlapping(IntervalL.of(26, 28));
 // o == [[20, 30], [25, 30]];

Interval trees contain values of type IntervalType<S> for some scalar type S. The following implementations are provided:

Type Description
IntervalD Intervals with double-typed values
IntervalB Intervals with BigInteger-typed values
IntervalL Intervals with long-typed values
IntervalI Intervals with int-typed values

Notes

Credit is given to someone named "John Hargrove" who published what appears to be the only comprehensible explanation of AVL tree rotations online. All other texts appear to contain subtle mistakes, or miss the exact conditions required for each rotation type to be applicable.

He originally published a document online, but I've included a copy in the references subdirectory as I do not trust random files published in the home directories of computer science students on university servers to stay accessible.