itree

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2025 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package itree provides an interval tree implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparable

type Comparable[V any] interface {
	Compare(other V) int
}

Comparable is an interface for types that can be compared.

type ITree

type ITree[K Comparable[K], V any] struct {
	// contains filtered or unexported fields
}

ITree represents an interval tree.

func NewITree

func NewITree[K Comparable[K], V any]() *ITree[K, V]

NewITree creates a new interval tree.

func (*ITree[K, V]) Insert

func (t *ITree[K, V]) Insert(interval Interval[K], value V)

Insert adds an interval to the interval tree.

func (*ITree[K, V]) Query

func (t *ITree[K, V]) Query(key K) []V

Query returns the values associated with the intervals that contain the given key.

type Interval

type Interval[V Comparable[V]] struct {
	Low  V
	High V
}

Interval represents the `[Low, High]` interval (inclusive).

func NewInterval

func NewInterval[V Comparable[V]](low, high V) Interval[V]

NewInterval creates a new interval with the given low and high values.

func (Interval[V]) Contains

func (i Interval[V]) Contains(value V) bool

Contains returns whether the interval contains the given value.

type Node

type Node[K Comparable[K], V any] struct {
	// contains filtered or unexported fields
}

Node represents a node in the interval tree.

func NewNode

func NewNode[K Comparable[K], V any](
	interval Interval[K],
	value V,
) *Node[K, V]

NewNode creates a new node with the given interval.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL