segments

package
v2.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff[P any, S Segment[P], StepT comparable, D Diffabble[P, StepT]](
	haves []S, needs []S, step StepT, diff D,
) []S

Diff compares haves to needs and returns a []Segments missing from needs

Types

type Diffabble

type Diffabble[P any, StepT any] interface {
	Add(a P, step StepT) P
	Less(a, b P) bool
	Equal(a, b P) bool
	Zero() P
	Neg(step StepT) StepT
}

Diffabble is a named type of a slice of an implementation of Segment that can be passed into Difference() as diff D

type Int64

type Int64 struct{}

Int64 implements Diffable for int64 (bytes, IPv4s, etc.)

func (Int64) Add

func (Int64) Add(a int64, step int64) int64

func (Int64) Equal

func (Int64) Equal(a, b int64) bool

func (Int64) Less

func (Int64) Less(a, b int64) bool

func (Int64) Neg

func (Int64) Neg(step int64) int64

func (Int64) Zero

func (Int64) Zero() int64

type Segment

type Segment[U any] interface {
	StartVal() U
	EndVal() U
	NewSegment(start, end U) Segment[U]
	String() string
}

Segment represents a range with inclusive Start/End points of type U.

type Time

type Time struct{}

Time implements Diffable for time.Time

func (Time) Add

func (Time) Add(a time.Time, step time.Duration) time.Time

func (Time) Equal

func (Time) Equal(a, b time.Time) bool

func (Time) Less

func (Time) Less(a, b time.Time) bool

func (Time) Neg

func (Time) Neg(step time.Duration) time.Duration

func (Time) Zero

func (Time) Zero() time.Time

Jump to

Keyboard shortcuts

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