container

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color bool
const (
	Black Color = false
	Red   Color = true
)

type Comparable

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

type Direction

type Direction uint8
const (
	Left  Direction = 0
	Right Direction = 1
)

type Interval

type Interval[T constraints.Ordered] struct {
	Min, Max T
}

func (Interval[T]) Compare

func (ival Interval[T]) Compare(oval Interval[T]) int

func (Interval[T]) Overlaps

func (ival Interval[T]) Overlaps(oval Interval[T]) bool

func (Interval[T]) SupersetOf

func (ival Interval[T]) SupersetOf(oval Interval[T]) bool

type IntervalTree

type IntervalTree[T constraints.Ordered, V any] struct {
	RBTree[Interval[T], Value[T, V]]
}

func NewIntervalTree

func NewIntervalTree[T constraints.Ordered, V any]() *IntervalTree[T, V]

func (*IntervalTree[T, V]) Find

func (t *IntervalTree[T, V]) Find(
	min T,
	max T,
	out []*RBNode[Interval[T], Value[T, V]],
) []*RBNode[Interval[T], Value[T, V]]

func (*IntervalTree[T, V]) FindIter

func (t *IntervalTree[T, V]) FindIter(
	min T,
	max T,
	cb func(node *RBNode[Interval[T], Value[T, V]]) bool,
)

func (*IntervalTree[T, V]) Insert

func (t *IntervalTree[T, V]) Insert(min, max T, value V) *RBNode[Interval[T], Value[T, V]]

type Option added in v0.4.0

type Option[T any] struct {
	// contains filtered or unexported fields
}

func None added in v0.4.0

func None[T any]() Option[T]

func Some added in v0.4.0

func Some[T any](v T) Option[T]

func (Option[T]) Get added in v0.4.0

func (m Option[T]) Get() (T, bool)

func (Option[T]) GetOr added in v0.4.0

func (m Option[T]) GetOr(alt T) T

type RBNode

type RBNode[K Comparable[K], V any] struct {
	Parent   *RBNode[K, V]
	Children [2]*RBNode[K, V]
	Key      K
	Values   []V
	// contains filtered or unexported fields
}

func NewRBNode

func NewRBNode[K Comparable[K], V any](k K, v V) *RBNode[K, V]

func (*RBNode[K, V]) Dot

func (n *RBNode[K, V]) Dot(w io.Writer, meta func(n *RBNode[K, V]) string)

func (*RBNode[K, V]) Inorder added in v0.4.0

func (t *RBNode[K, V]) Inorder(yield func(K, V) bool) bool

type RBTree

type RBTree[K Comparable[K], V any] struct {
	Root            *RBNode[K, V]
	NumValues       int
	AllowDuplicates bool

	Rotated func(node *RBNode[K, V])
}

func (*RBTree[K, V]) Inorder added in v0.4.0

func (t *RBTree[K, V]) Inorder(yield func(K, V) bool)

func (*RBTree[K, V]) Insert

func (t *RBTree[K, V]) Insert(k K, v V) *RBNode[K, V]

func (*RBTree[K, V]) Search

func (t *RBTree[K, V]) Search(k K) (node *RBNode[K, V], found bool, dir Direction)

type Set added in v0.4.0

type Set[T comparable] map[T]struct{}

func (Set[T]) Add added in v0.4.0

func (set Set[T]) Add(v T)

func (Set[T]) Delete added in v0.4.0

func (set Set[T]) Delete(v T)

type Value

type Value[T constraints.Ordered, V any] struct {
	MaxSubtree T
	Value      V
}

Jump to

Keyboard shortcuts

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