monad

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparable

type Comparable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64 |
		~string
}

Comparable is a type constraint for types that support comparison operations. It includes all numeric types and strings.

type Range

type Range[T Comparable] struct {
	Start T // Start is the inclusive start of the range
	End   T // End is the inclusive end of the range
}

Range represents an inclusive range of comparable values [Start, End].

func NewRange

func NewRange[T Comparable](start, end T) Range[T]

NewRange creates a new range with the given start and end values. The range is inclusive on both ends: [start, end].

func (Range[T]) Contains

func (r Range[T]) Contains(value T) bool

Contains checks if the range contains the given value (inclusive). Returns true if start <= value <= end.

func (Range[T]) Intersection

func (r Range[T]) Intersection(other Range[T]) Range[T]

Intersection returns the intersection of this range with another range. Returns an empty range if there is no intersection.

func (Range[T]) IsEmpty

func (r Range[T]) IsEmpty() bool

IsEmpty returns true if the range contains no values (start > end).

func (Range[T]) IsValid

func (r Range[T]) IsValid() bool

IsValid checks if the range is valid (start <= end).

func (Range[T]) Overlaps

func (r Range[T]) Overlaps(other Range[T]) bool

Overlaps checks if this range overlaps with another range.

Jump to

Keyboard shortcuts

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