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 ¶
- type Int
- type Int32
- func (d Int32) Distance(start, end int32) (int64, error)
- func (d Int32) MaxValue() int32
- func (d Int32) MinValue() int32
- func (d Int32) Next(v int32) (int32, error)
- func (d Int32) Offset(origin int32, distance uint64) (int32, error)
- func (d Int32) Previous(v int32) (int32, error)
- func (d Int32) String() string
- type Int64
- func (d Int64) Distance(start, end int64) (int64, error)
- func (d Int64) MaxValue() int64
- func (d Int64) MinValue() int64
- func (d Int64) Next(v int64) (int64, error)
- func (d Int64) Offset(origin int64, distance uint64) (int64, error)
- func (d Int64) Previous(v int64) (int64, error)
- func (d Int64) String() string
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
type Int32 ¶
type Int32 struct { }
Int32 is the discrete domain for values of type int32.
func (Int32) Distance ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
type Int64 ¶
type Int64 struct { }
Int64 is the discrete domain for values of type int64.
func (Int64) Distance ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.