Documentation
¶
Index ¶
- Variables
- type Basis
- func (b Basis[T]) After(i1, i2 Interval[T]) bool
- func (b Basis[T]) Before(i1, i2 Interval[T]) bool
- func (b Basis[T]) Closed(L, R T) Interval[T]
- func (b Basis[T]) EndsAfter(i1, i2 Interval[T]) bool
- func (b Basis[T]) Intersect(i1, i2 Interval[T]) (Interval[T], bool)
- func (b Basis[T]) Negate(i Interval[T]) []Interval[T]
- func (b Basis[T]) Open(L, R T) Interval[T]
- func (b Basis[T]) OpenL(L, R T) Interval[T]
- func (b Basis[T]) OpenR(L, R T) Interval[T]
- func (b Basis[T]) StartsBefore(i1, i2 Interval[T]) bool
- func (b Basis[T]) Union(i1, i2 Interval[T]) (Interval[T], bool)
- type Interval
Constants ¶
This section is empty.
Variables ¶
var ( // BasisInt is a default basis for type int BasisInt = NewBasis(math.MinInt, math.MaxInt, cmp.Compare[int]) // BasisString is a default basis for type string BasisString = NewBasis("", string(utf8.MaxRune), cmp.Compare[string]) // BasisTime is a default basis for type time.Time BasisTime = NewBasis( time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2070, 1, 1, 0, 0, 0, 0, time.UTC), func(t1, t2 time.Time) int { if t1.Before(t2) { return -1 } if t1.Equal(t2) { return 0 } return 1 }, ) )
Functions ¶
This section is empty.
Types ¶
type Basis ¶
type Basis[T any] struct { Min T // min value of the type T Max T // max value of the type T CmpF func(v1, v2 T) int // comparison function of T type values }
Basis represents a basis for a set of vectors, it defines what [min,max] range the vectors have and what operations are available for the vectors, like: create, intersect, union, etc.
func (Basis[T]) After ¶
After returns true if the L border of the i1 interval is lesser than the R border of the i2 interval. NOTE: The `(L=1, R=3)` and `(L=2, R=4)` intervals are considered to have an intersection (see Intersection description) and the `(L=2, R=4).After.((L=1, R=3))` call returns false.
func (Basis[T]) Before ¶
Before returns true if the R border of i1 interval is lesser than the L border of the i2 interval. NOTE: The `(L=1, R=3)` and `(L=2, R=4)` intervals are considered to have an intersection (see Intersection description) and the `(L=1, R=3).Before.((L=2, R=4))` call returns false.
func (Basis[T]) Closed ¶
func (b Basis[T]) Closed(L, R T) Interval[T]
Closed creates a closed interval `[1, 5]`
func (Basis[T]) EndsAfter ¶
EndsAfter returns true if the R border of the i1 interval is greater than the R border of the i2 interval. NOTE: The `..., R=5)` and `..., R=4]` ends are equivalent, but the function returns true for `(L=2, R=5).EndsAfter([L=3, R=4])`.
func (Basis[T]) Intersect ¶
Intersect returns the intersection of the i1 interval with the i2 interval. If no intersection is found the function returns false in the second return value. NOTE: The `(L=1, R=3)` and `(L=2, R=4)` intervals are considered to have an intersection and the `(L=1, R=3).Intersect((L=2, R=4))` call returns `(L=2, R=3)`.
func (Basis[T]) Negate ¶
func (b Basis[T]) Negate(i Interval[T]) []Interval[T]
Negate negates the current interval, meaning that it returns the complement of the current interval.
func (Basis[T]) Open ¶
func (b Basis[T]) Open(L, R T) Interval[T]
Open create an open interval `(1, 5)`
func (Basis[T]) OpenL ¶
func (b Basis[T]) OpenL(L, R T) Interval[T]
OpenL create a left-open interval `(1, 5]`
func (Basis[T]) OpenR ¶
func (b Basis[T]) OpenR(L, R T) Interval[T]
OpenR creates a right-open interval `[1, 5)`
func (Basis[T]) StartsBefore ¶
StartsBefore returns true if the L border of the i1 interval is lesser than the L border of the i2 interval. NOTE: The `(L=2, ...` and `[L=3, ...` starts are equivalent, but the function returns true for `(L=2, R=5).StartsBefore([L=3, R=4])`.
func (Basis[T]) Union ¶
Union returns the union of the i1 interval with the i2 interval only if there is an intersection. If no intersection is found the function returns false in the second return value. NOTE: The `(L=1, R=3)` and `(L=2, R=4)` intervals are considered to have an intersection (see Intersection description) the `(L=1, R=3).Union((L=2, R=4))` call returns `(L=1, R=4)`.
type Interval ¶
Interval represents an interval of values of type T, interval can be open, half-open, closed.
func (Interval[T]) IsClosed ¶
func (i Interval[T]) IsClosed() bool
IsClosed returns true if interval is closed
func (Interval[T]) IsOpen ¶
func (i Interval[T]) IsOpen() bool
IsOpen returns true if interval is open
func (Interval[T]) IsOpenL ¶
func (i Interval[T]) IsOpenL() bool
IsOpenL returns true if interval is left-open