interval: github.com/cznic/interval Index | Examples | Files

package interval

import "github.com/cznic/interval"

Package interval handles sets of ordered values laying between two, possibly infinite, bounds.

Note: Intervals are usually defined as a set of [extended] real numbers. The model of the interval provided by Interface does not know - and thus does not care about the type of the bounds, if any. That may lead to correct but possibly surprising effects when the bounds domain is not ℝ. An interval may be non empty, like for example the open interval (1, 2), but no integer value lies between the bounds.

See also: http://en.wikipedia.org/wiki/Interval_(mathematics)

Index

Examples

Package Files

class_string.go gen.go interval.go

type BigInt Uses

type BigInt struct {
    Cls  Class
    A, B *big.Int
}

BigInt is an interval having math/big.Int bounds.

Code:

x := &BigInt{LeftOpen, big.NewInt(1), big.NewInt(2)}
y := &BigInt{LeftClosed, big.NewInt(2), big.NewInt(3)}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*BigInt) Class Uses

func (i *BigInt) Class() Class

Class implements Interface.

func (*BigInt) Clone Uses

func (i *BigInt) Clone() Interface

Clone implements Interface.

func (*BigInt) CompareAA Uses

func (i *BigInt) CompareAA(other Interface) int

CompareAA implements Interface.

func (*BigInt) CompareAB Uses

func (i *BigInt) CompareAB(other Interface) int

CompareAB implements Interface.

func (*BigInt) CompareBB Uses

func (i *BigInt) CompareBB(other Interface) int

CompareBB implements Interface.

func (*BigInt) SetAB Uses

func (i *BigInt) SetAB()

SetAB implements Interface.

func (*BigInt) SetB Uses

func (i *BigInt) SetB(other Interface)

SetB implements Interface.

func (*BigInt) SetBA Uses

func (i *BigInt) SetBA(other Interface)

SetBA implements Interface.

func (*BigInt) SetClass Uses

func (i *BigInt) SetClass(c Class)

SetClass implements Interface.

func (*BigInt) String Uses

func (i *BigInt) String() string

String implements fmt.Stringer.

type BigRat Uses

type BigRat struct {
    Cls  Class
    A, B *big.Rat
}

BigRat is an interval having math/big.Rat bounds.

Code:

x := &BigRat{LeftOpen, big.NewRat(1, 1), big.NewRat(2, 1)}
y := &BigRat{LeftClosed, big.NewRat(2, 1), big.NewRat(3, 1)}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1/1, 2/1], y [2/1, 3/1): x ∩ y {2/1}, x ∪ y (1/1, 3/1)

func (*BigRat) Class Uses

func (i *BigRat) Class() Class

Class implements Interface.

func (*BigRat) Clone Uses

func (i *BigRat) Clone() Interface

Clone implements Interface.

func (*BigRat) CompareAA Uses

func (i *BigRat) CompareAA(other Interface) int

CompareAA implements Interface.

func (*BigRat) CompareAB Uses

func (i *BigRat) CompareAB(other Interface) int

CompareAB implements Interface.

func (*BigRat) CompareBB Uses

func (i *BigRat) CompareBB(other Interface) int

CompareBB implements Interface.

func (*BigRat) SetAB Uses

func (i *BigRat) SetAB()

SetAB implements Interface.

func (*BigRat) SetB Uses

func (i *BigRat) SetB(other Interface)

SetB implements Interface.

func (*BigRat) SetBA Uses

func (i *BigRat) SetBA(other Interface)

SetBA implements Interface.

func (*BigRat) SetClass Uses

func (i *BigRat) SetClass(c Class)

SetClass implements Interface.

func (*BigRat) String Uses

func (i *BigRat) String() string

String implements fmt.Stringer.

type Byte Uses

type Byte struct {
    Cls  Class
    A, B byte
}

Byte is an interval having byte bounds.

Code:

x := &Byte{LeftOpen, 1, 2}
y := &Byte{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Byte) Class Uses

func (i *Byte) Class() Class

Class implements Interface.

func (*Byte) Clone Uses

func (i *Byte) Clone() Interface

Clone implements Interface.

func (*Byte) CompareAA Uses

func (i *Byte) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Byte) CompareAB Uses

func (i *Byte) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Byte) CompareBB Uses

func (i *Byte) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Byte) SetAB Uses

func (i *Byte) SetAB()

SetAB implements Interface.

func (*Byte) SetB Uses

func (i *Byte) SetB(other Interface)

SetB implements Interface.

func (*Byte) SetBA Uses

func (i *Byte) SetBA(other Interface)

SetBA implements Interface.

func (*Byte) SetClass Uses

func (i *Byte) SetClass(c Class)

SetClass implements Interface.

func (*Byte) String Uses

func (i *Byte) String() string

String implements fmt.Stringer.

type Class Uses

type Class int

Class represent a type of an interval.

const (
    Unbounded  Class = iota // (-∞, ∞).
    Empty                   // {}.
    Degenerate              // [a, a] = {a}.

    // Proper and bounded:
    Open       // (a, b) = {x | a < x < b}.
    Closed     // [a, b] = {x | a <= x <= b}.
    LeftOpen   // (a, b] = {x | a < x <= b}.
    LeftClosed // [a, b) = {x | a <= x < b}.

    // Left-bounded and right-unbounded:
    LeftBoundedOpen   // (a, ∞) = {x | x > a}.
    LeftBoundedClosed // [a, ∞) = {x | x >= a}.

    // Left-unbounded and right-bounded:
    RightBoundedOpen   // (-∞, b) = {x | x < b}.
    RightBoundedClosed // (-∞, b] = {x | x <= b}.

)

Interval classes.

func (Class) String Uses

func (i Class) String() string

type Duration Uses

type Duration struct {
    Cls  Class
    A, B time.Duration
}

Duration is an interval having time.Duration bounds.

Code:

x := &Duration{LeftOpen, 1, 2}
y := &Duration{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1ns, 2ns], y [2ns, 3ns): x ∩ y {2ns}, x ∪ y (1ns, 3ns)

func (*Duration) Class Uses

func (i *Duration) Class() Class

Class implements Interface.

func (*Duration) Clone Uses

func (i *Duration) Clone() Interface

Clone implements Interface.

func (*Duration) CompareAA Uses

func (i *Duration) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Duration) CompareAB Uses

func (i *Duration) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Duration) CompareBB Uses

func (i *Duration) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Duration) SetAB Uses

func (i *Duration) SetAB()

SetAB implements Interface.

func (*Duration) SetB Uses

func (i *Duration) SetB(other Interface)

SetB implements Interface.

func (*Duration) SetBA Uses

func (i *Duration) SetBA(other Interface)

SetBA implements Interface.

func (*Duration) SetClass Uses

func (i *Duration) SetClass(c Class)

SetClass implements Interface.

func (*Duration) String Uses

func (i *Duration) String() string

String implements fmt.Stringer.

type Float32 Uses

type Float32 struct {
    Cls  Class
    A, B float32
}

Float32 is an interval having float32 bounds.

Note: Using NaNs as bounds has undefined behavior.

Code:

x := &Float32{LeftOpen, 1, 2}
y := &Float32{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Float32) Class Uses

func (i *Float32) Class() Class

Class implements Interface.

func (*Float32) Clone Uses

func (i *Float32) Clone() Interface

Clone implements Interface.

func (*Float32) CompareAA Uses

func (i *Float32) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Float32) CompareAB Uses

func (i *Float32) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Float32) CompareBB Uses

func (i *Float32) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Float32) SetAB Uses

func (i *Float32) SetAB()

SetAB implements Interface.

func (*Float32) SetB Uses

func (i *Float32) SetB(other Interface)

SetB implements Interface.

func (*Float32) SetBA Uses

func (i *Float32) SetBA(other Interface)

SetBA implements Interface.

func (*Float32) SetClass Uses

func (i *Float32) SetClass(c Class)

SetClass implements Interface.

func (*Float32) String Uses

func (i *Float32) String() string

String implements fmt.Stringer.

type Float64 Uses

type Float64 struct {
    Cls  Class
    A, B float64
}

Float64 is an interval having float64 bounds.

Note: Using NaNs as bounds has undefined behavior.

Code:

x := &Float32{LeftOpen, 1, 2}
y := &Float32{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Float64) Class Uses

func (i *Float64) Class() Class

Class implements Interface.

func (*Float64) Clone Uses

func (i *Float64) Clone() Interface

Clone implements Interface.

func (*Float64) CompareAA Uses

func (i *Float64) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Float64) CompareAB Uses

func (i *Float64) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Float64) CompareBB Uses

func (i *Float64) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Float64) SetAB Uses

func (i *Float64) SetAB()

SetAB implements Interface.

func (*Float64) SetB Uses

func (i *Float64) SetB(other Interface)

SetB implements Interface.

func (*Float64) SetBA Uses

func (i *Float64) SetBA(other Interface)

SetBA implements Interface.

func (*Float64) SetClass Uses

func (i *Float64) SetClass(c Class)

SetClass implements Interface.

func (*Float64) String Uses

func (i *Float64) String() string

String implements fmt.Stringer.

type Int Uses

type Int struct {
    Cls  Class
    A, B int
}

Int is an interval having int bounds.

Code:

x := &Int{LeftOpen, 1, 2}
y := &Int{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int) Class Uses

func (i *Int) Class() Class

Class implements Interface.

func (*Int) Clone Uses

func (i *Int) Clone() Interface

Clone implements Interface.

func (*Int) CompareAA Uses

func (i *Int) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int) CompareAB Uses

func (i *Int) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int) CompareBB Uses

func (i *Int) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int) SetAB Uses

func (i *Int) SetAB()

SetAB implements Interface.

func (*Int) SetB Uses

func (i *Int) SetB(other Interface)

SetB implements Interface.

func (*Int) SetBA Uses

func (i *Int) SetBA(other Interface)

SetBA implements Interface.

func (*Int) SetClass Uses

func (i *Int) SetClass(c Class)

SetClass implements Interface.

func (*Int) String Uses

func (i *Int) String() string

String implements fmt.Stringer.

type Int128 Uses

type Int128 struct {
    Cls  Class
    A, B mathutil.Int128
}

Int128 is an interval having Int128 bounds.

Code:

x := &Int128{LeftOpen, int128.SetInt64(1), int128.SetInt64(2)}
y := &Int128{LeftClosed, int128.SetInt64(2), int128.SetInt64(3)}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int128) Class Uses

func (i *Int128) Class() Class

Class implements Interface.

func (*Int128) Clone Uses

func (i *Int128) Clone() Interface

Clone implements Interface.

func (*Int128) CompareAA Uses

func (i *Int128) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int128) CompareAB Uses

func (i *Int128) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int128) CompareBB Uses

func (i *Int128) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int128) SetAB Uses

func (i *Int128) SetAB()

SetAB implements Interface.

func (*Int128) SetB Uses

func (i *Int128) SetB(other Interface)

SetB implements Interface.

func (*Int128) SetBA Uses

func (i *Int128) SetBA(other Interface)

SetBA implements Interface.

func (*Int128) SetClass Uses

func (i *Int128) SetClass(c Class)

SetClass implements Interface.

func (*Int128) String Uses

func (i *Int128) String() string

String implements fmt.Stringer.

type Int16 Uses

type Int16 struct {
    Cls  Class
    A, B int16
}

Int16 is an interval having int16 bounds.

Code:

x := &Int16{LeftOpen, 1, 2}
y := &Int16{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int16) Class Uses

func (i *Int16) Class() Class

Class implements Interface.

func (*Int16) Clone Uses

func (i *Int16) Clone() Interface

Clone implements Interface.

func (*Int16) CompareAA Uses

func (i *Int16) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int16) CompareAB Uses

func (i *Int16) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int16) CompareBB Uses

func (i *Int16) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int16) SetAB Uses

func (i *Int16) SetAB()

SetAB implements Interface.

func (*Int16) SetB Uses

func (i *Int16) SetB(other Interface)

SetB implements Interface.

func (*Int16) SetBA Uses

func (i *Int16) SetBA(other Interface)

SetBA implements Interface.

func (*Int16) SetClass Uses

func (i *Int16) SetClass(c Class)

SetClass implements Interface.

func (*Int16) String Uses

func (i *Int16) String() string

String implements fmt.Stringer.

type Int32 Uses

type Int32 struct {
    Cls  Class
    A, B int32
}

Int32 is an interval having int32 bounds.

Code:

x := &Int32{LeftOpen, 1, 2}
y := &Int32{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int32) Class Uses

func (i *Int32) Class() Class

Class implements Interface.

func (*Int32) Clone Uses

func (i *Int32) Clone() Interface

Clone implements Interface.

func (*Int32) CompareAA Uses

func (i *Int32) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int32) CompareAB Uses

func (i *Int32) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int32) CompareBB Uses

func (i *Int32) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int32) SetAB Uses

func (i *Int32) SetAB()

SetAB implements Interface.

func (*Int32) SetB Uses

func (i *Int32) SetB(other Interface)

SetB implements Interface.

func (*Int32) SetBA Uses

func (i *Int32) SetBA(other Interface)

SetBA implements Interface.

func (*Int32) SetClass Uses

func (i *Int32) SetClass(c Class)

SetClass implements Interface.

func (*Int32) String Uses

func (i *Int32) String() string

String implements fmt.Stringer.

type Int64 Uses

type Int64 struct {
    Cls  Class
    A, B int64
}

Int64 is an interval having int64 bounds.

Code:

x := &Int64{LeftOpen, 1, 2}
y := &Int64{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int64) Class Uses

func (i *Int64) Class() Class

Class implements Interface.

func (*Int64) Clone Uses

func (i *Int64) Clone() Interface

Clone implements Interface.

func (*Int64) CompareAA Uses

func (i *Int64) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int64) CompareAB Uses

func (i *Int64) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int64) CompareBB Uses

func (i *Int64) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int64) SetAB Uses

func (i *Int64) SetAB()

SetAB implements Interface.

func (*Int64) SetB Uses

func (i *Int64) SetB(other Interface)

SetB implements Interface.

func (*Int64) SetBA Uses

func (i *Int64) SetBA(other Interface)

SetBA implements Interface.

func (*Int64) SetClass Uses

func (i *Int64) SetClass(c Class)

SetClass implements Interface.

func (*Int64) String Uses

func (i *Int64) String() string

String implements fmt.Stringer.

type Int8 Uses

type Int8 struct {
    Cls  Class
    A, B int8
}

Int8 is an interval having int8 bounds.

Code:

x := &Int8{LeftOpen, 1, 2}
y := &Int8{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Int8) Class Uses

func (i *Int8) Class() Class

Class implements Interface.

func (*Int8) Clone Uses

func (i *Int8) Clone() Interface

Clone implements Interface.

func (*Int8) CompareAA Uses

func (i *Int8) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Int8) CompareAB Uses

func (i *Int8) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Int8) CompareBB Uses

func (i *Int8) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Int8) SetAB Uses

func (i *Int8) SetAB()

SetAB implements Interface.

func (*Int8) SetB Uses

func (i *Int8) SetB(other Interface)

SetB implements Interface.

func (*Int8) SetBA Uses

func (i *Int8) SetBA(other Interface)

SetBA implements Interface.

func (*Int8) SetClass Uses

func (i *Int8) SetClass(c Class)

SetClass implements Interface.

func (*Int8) String Uses

func (i *Int8) String() string

String implements fmt.Stringer.

type Interface Uses

type Interface interface {
    // Class returns the interval class.
    Class() Class
    // Clone clones the interval.
    Clone() Interface
    // CompareAA compares interval.A and other.A.
    CompareAA(other Interface) int
    // CompareAB compares interval.A and other.B.
    CompareAB(other Interface) int
    // CompareBB compares interval.B and other.B.
    CompareBB(other Interface) int
    // SetClass sets the interval class.
    SetClass(Class)
    // SetAB sets interval.A using interval.B.
    SetAB()
    // SetB sets interval.B using other.B.
    SetB(other Interface)
    // SetBA sets interval.B using other.A.
    SetBA(other Interface)
}

Interface represents an unbounded, empty, degenerate, proper, left-bounded or right-bounded interval. Where appropriate, the interval bounds are defined by ordered values, named by convention a and b, when present.

Proper intervals have an invariant: a < b.

CompareXX return value must obey these rules

< 0 if interval A or B <  other interval A or B
  0 if interval A or B == other interval A or B
> 0 if interval A or B >  other interval A or B

func Intersection Uses

func Intersection(x, y Interface) Interface

Intersection returns the intersection of x and y.

func Union Uses

func Union(x, y Interface) Interface

Union returns the union of x and y. If the union is not an interval, nil is returned instead. The union is not an interval if it is a disjoint set.

type String Uses

type String struct {
    Cls  Class
    A, B string
}

String is an interval having string bounds.

Code:

x := &String{LeftOpen, "aqua", "bar"}
y := &String{LeftClosed, "bar", "closed"}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (aqua, bar], y [bar, closed): x ∩ y {bar}, x ∪ y (aqua, closed)

func (*String) Class Uses

func (i *String) Class() Class

Class implements Interface.

func (*String) Clone Uses

func (i *String) Clone() Interface

Clone implements Interface.

func (*String) CompareAA Uses

func (i *String) CompareAA(other Interface) int

CompareAA implements Interface.

func (*String) CompareAB Uses

func (i *String) CompareAB(other Interface) int

CompareAB implements Interface.

func (*String) CompareBB Uses

func (i *String) CompareBB(other Interface) int

CompareBB implements Interface.

func (*String) SetAB Uses

func (i *String) SetAB()

SetAB implements Interface.

func (*String) SetB Uses

func (i *String) SetB(other Interface)

SetB implements Interface.

func (*String) SetBA Uses

func (i *String) SetBA(other Interface)

SetBA implements Interface.

func (*String) SetClass Uses

func (i *String) SetClass(c Class)

SetClass implements Interface.

func (*String) String Uses

func (i *String) String() string

String implements fmt.Stringer.

type Time Uses

type Time struct {
    Cls  Class
    A, B time.Time
}

Time is an interval having time.Time bounds.

Code:

x := &Time{LeftOpen, time.Unix(1, 0), time.Unix(2, 0)}
y := &Time{LeftClosed, time.Unix(2, 0), time.Unix(3, 0)}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1970-01-01 01:00:01 +0100 CET, 1970-01-01 01:00:02 +0100 CET], y [1970-01-01 01:00:02 +0100 CET, 1970-01-01 01:00:03 +0100 CET): x ∩ y {1970-01-01 01:00:02 +0100 CET}, x ∪ y (1970-01-01 01:00:01 +0100 CET, 1970-01-01 01:00:03 +0100 CET)

func (*Time) Class Uses

func (i *Time) Class() Class

Class implements Interface.

func (*Time) Clone Uses

func (i *Time) Clone() Interface

Clone implements Interface.

func (*Time) CompareAA Uses

func (i *Time) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Time) CompareAB Uses

func (i *Time) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Time) CompareBB Uses

func (i *Time) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Time) SetAB Uses

func (i *Time) SetAB()

SetAB implements Interface.

func (*Time) SetB Uses

func (i *Time) SetB(other Interface)

SetB implements Interface.

func (*Time) SetBA Uses

func (i *Time) SetBA(other Interface)

SetBA implements Interface.

func (*Time) SetClass Uses

func (i *Time) SetClass(c Class)

SetClass implements Interface.

func (*Time) String Uses

func (i *Time) String() string

String implements fmt.Stringer.

type Uint Uses

type Uint struct {
    Cls  Class
    A, B uint
}

Uint is an interval having uint bounds.

Code:

x := &Uint{LeftOpen, 1, 2}
y := &Uint{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Uint) Class Uses

func (i *Uint) Class() Class

Class implements Interface.

func (*Uint) Clone Uses

func (i *Uint) Clone() Interface

Clone implements Interface.

func (*Uint) CompareAA Uses

func (i *Uint) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Uint) CompareAB Uses

func (i *Uint) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Uint) CompareBB Uses

func (i *Uint) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Uint) SetAB Uses

func (i *Uint) SetAB()

SetAB implements Interface.

func (*Uint) SetB Uses

func (i *Uint) SetB(other Interface)

SetB implements Interface.

func (*Uint) SetBA Uses

func (i *Uint) SetBA(other Interface)

SetBA implements Interface.

func (*Uint) SetClass Uses

func (i *Uint) SetClass(c Class)

SetClass implements Interface.

func (*Uint) String Uses

func (i *Uint) String() string

String implements fmt.Stringer.

type Uint16 Uses

type Uint16 struct {
    Cls  Class
    A, B uint16
}

Uint16 is an interval having uint16 bounds.

Code:

x := &Uint16{LeftOpen, 1, 2}
y := &Uint16{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Uint16) Class Uses

func (i *Uint16) Class() Class

Class implements Interface.

func (*Uint16) Clone Uses

func (i *Uint16) Clone() Interface

Clone implements Interface.

func (*Uint16) CompareAA Uses

func (i *Uint16) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Uint16) CompareAB Uses

func (i *Uint16) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Uint16) CompareBB Uses

func (i *Uint16) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Uint16) SetAB Uses

func (i *Uint16) SetAB()

SetAB implements Interface.

func (*Uint16) SetB Uses

func (i *Uint16) SetB(other Interface)

SetB implements Interface.

func (*Uint16) SetBA Uses

func (i *Uint16) SetBA(other Interface)

SetBA implements Interface.

func (*Uint16) SetClass Uses

func (i *Uint16) SetClass(c Class)

SetClass implements Interface.

func (*Uint16) String Uses

func (i *Uint16) String() string

String implements fmt.Stringer.

type Uint32 Uses

type Uint32 struct {
    Cls  Class
    A, B uint32
}

Uint32 is an interval having uint32 bounds.

Code:

x := &Uint32{LeftOpen, 1, 2}
y := &Uint32{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Uint32) Class Uses

func (i *Uint32) Class() Class

Class implements Interface.

func (*Uint32) Clone Uses

func (i *Uint32) Clone() Interface

Clone implements Interface.

func (*Uint32) CompareAA Uses

func (i *Uint32) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Uint32) CompareAB Uses

func (i *Uint32) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Uint32) CompareBB Uses

func (i *Uint32) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Uint32) SetAB Uses

func (i *Uint32) SetAB()

SetAB implements Interface.

func (*Uint32) SetB Uses

func (i *Uint32) SetB(other Interface)

SetB implements Interface.

func (*Uint32) SetBA Uses

func (i *Uint32) SetBA(other Interface)

SetBA implements Interface.

func (*Uint32) SetClass Uses

func (i *Uint32) SetClass(c Class)

SetClass implements Interface.

func (*Uint32) String Uses

func (i *Uint32) String() string

String implements fmt.Stringer.

type Uint64 Uses

type Uint64 struct {
    Cls  Class
    A, B uint64
}

Uint64 is an interval having uint64 bounds.

Code:

x := &Uint64{LeftOpen, 1, 2}
y := &Uint64{LeftClosed, 2, 3}
fmt.Printf("x %v, y %v: x ∩ y %v, x ∪ y %v", x, y, Intersection(x, y), Union(x, y))

Output:

x (1, 2], y [2, 3): x ∩ y {2}, x ∪ y (1, 3)

func (*Uint64) Class Uses

func (i *Uint64) Class() Class

Class implements Interface.

func (*Uint64) Clone Uses

func (i *Uint64) Clone() Interface

Clone implements Interface.

func (*Uint64) CompareAA Uses

func (i *Uint64) CompareAA(other Interface) int

CompareAA implements Interface.

func (*Uint64) CompareAB Uses

func (i *Uint64) CompareAB(other Interface) int

CompareAB implements Interface.

func (*Uint64) CompareBB Uses

func (i *Uint64) CompareBB(other Interface) int

CompareBB implements Interface.

func (*Uint64) SetAB Uses

func (i *Uint64) SetAB()

SetAB implements Interface.

func (*Uint64) SetB Uses

func (i *Uint64) SetB(other Interface)

SetB implements Interface.

func (*Uint64) SetBA Uses

func (i *Uint64) SetBA(other Interface)

SetBA implements Interface.

func (*Uint64) SetClass Uses

func (i *Uint64) SetClass(c Class)

SetClass implements Interface.

func (*Uint64) String Uses

func (i *Uint64) String() string

String implements fmt.Stringer.

Package interval imports 4 packages (graph) and is imported by 1 packages. Updated 2018-11-28. Refresh now. Tools for package owners.