domain

package
v0.0.0-...-7272a43 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package domain contains descriptors for discrete comparable domains such as all int instances.

A discrete domain is one that supports the three basic operations: Next, Previous and Distance, according to their specifications.

A discrete domain always represents the entire set of values of its type; it cannot represent partial domains such as "prime integers" or "strings of length 5."

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int

type Int struct {
}

Int is the discrete domain for values of type int.

func (Int) Distance

func (d Int) Distance(start, end int) (int64, error)

Distance returns a signed value indicating how many nested invocations of Next (if positive) or Previous (if negative) are needed to reach end starting from start.

For example, if end = Next(Next(Next(start))), then Distance(start, end) == 3 and Distance(end, start) == -3. As well, Distance(a, a) is always zero.

func (Int) MaxValue

func (d Int) MaxValue() int

MaxValue returns the maximum value of type int.

The maximum value m is the unique value for which o>m never returns a true for any value o of type int.

func (Int) MinValue

func (d Int) MinValue() int

MinValue returns the minimum value of type int.

The minimum value m is the unique value for which o<m never returns a true for any value o of type int.

func (Int) Next

func (d Int) Next(v int) (int, error)

Next returns the unique least value of type int that is greater than value, or an error if none exists.

Inverse operation to Previous.

func (Int) Offset

func (d Int) Offset(origin int, distance uint64) (int64, error)

Offset returns, conceptually, "origin + distance", or equivalently, the result of calling Next origin distance times.

Note that the calculation is done in int64 i.e., distance>math.MaxInt64 leads to an overflow error.

func (Int) Previous

func (d Int) Previous(v int) (int, error)

Previous returns the unique greatest value of type int that is less than value, or an error if none exists.

Inverse operation to Next.

func (Int) String

func (d Int) String() string

String returns a string representation of this domain.

type Int32

type Int32 struct {
}

Int32 is the discrete domain for values of type int32.

func (Int32) Distance

func (d Int32) Distance(start, end int32) (int64, error)

Distance returns a signed value indicating how many nested invocations of Next (if positive) or Previous (if negative) are needed to reach end starting from start.

For example, if end = Next(Next(Next(start))), then Distance(start, end) == 3 and Distance(end, start) == -3. As well, Distance(a, a) is always zero.

func (Int32) MaxValue

func (d Int32) MaxValue() int32

MaxValue returns the maximum value of type int32.

The maximum value m is the unique value for which o>m never returns a true for any value o of type int32.

func (Int32) MinValue

func (d Int32) MinValue() int32

MinValue returns the minimum value of type int32.

The minimum value m is the unique value for which o<m never returns a true for any value o of type int32.

func (Int32) Next

func (d Int32) Next(v int32) (int32, error)

Next returns the unique least value of type int32 that is greater than value, or an error if none exists.

Inverse operation to Previous.

func (Int32) Offset

func (d Int32) Offset(origin int32, distance uint64) (int32, error)

Offset returns, conceptually, "origin + distance", or equivalently, the result of calling Next origin distance times.

Note that the calculation is done in int64 i.e., distance>math.MaxInt64 leads to an overflow error.

func (Int32) Previous

func (d Int32) Previous(v int32) (int32, error)

Previous returns the unique greatest value of type int32 that is less than value, or an error if none exists.

Inverse operation to Next.

func (Int32) String

func (d Int32) String() string

String returns a string representation of this domain.

type Int64

type Int64 struct {
}

Int64 is the discrete domain for values of type int64.

func (Int64) Distance

func (d Int64) Distance(start, end int64) (int64, error)

Distance returns a signed value indicating how many nested invocations of Next (if positive) or Previous (if negative) are needed to reach end starting from start.

For example, if end = Next(Next(Next(start))), then Distance(start, end) == 3 and Distance(end, start) == -3. As well, Distance(a, a) is always zero.

func (Int64) MaxValue

func (d Int64) MaxValue() int64

MaxValue returns the maximum value of type int64.

The maximum value m is the unique value for which o>m never returns a true for any value o of type int64.

func (Int64) MinValue

func (d Int64) MinValue() int64

MinValue returns the minimum value of type int64.

The minimum value m is the unique value for which o<m never returns a true for any value o of type int64.

func (Int64) Next

func (d Int64) Next(v int64) (int64, error)

Next returns the unique least value of type int64 that is greater than value, or an error if none exists.

Inverse operation to Previous.

func (Int64) Offset

func (d Int64) Offset(origin int64, distance uint64) (int64, error)

Offset returns, conceptually, "origin + distance", or equivalently, the result of calling Next origin distance times.

Note that the calculation is done in int64 i.e., distance>math.MaxInt64 leads to an overflow error.

func (Int64) Previous

func (d Int64) Previous(v int64) (int64, error)

Previous returns the unique greatest value of type int64 that is less than value, or an error if none exists.

Inverse operation to Next.

func (Int64) String

func (d Int64) String() string

String returns a string representation of this domain.

Jump to

Keyboard shortcuts

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