Documentation ¶
Index ¶
- Variables
- type BoundType
- type EndPoint
- type Int16Value
- type Int32Value
- type Int64Value
- type Int8Value
- type Uint16Value
- type Uint32Value
- type Uint64Value
- type Uint8Value
- type Value
- type ValueRange
- func All() *ValueRange
- func AtLeast(lower Value) *ValueRange
- func AtMost(upper Value) *ValueRange
- func Closed(lower Value, upper Value) *ValueRange
- func ClosedOpen(lower Value, upper Value) *ValueRange
- func FromBytes(valueRangeBytes []byte) (valueRange *ValueRange, consumedBytes int, err error)
- func FromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (valueRange *ValueRange, err error)
- func GreaterThan(lower Value) *ValueRange
- func LessThan(upper Value) *ValueRange
- func Open(lower Value, upper Value) *ValueRange
- func OpenClosed(lower Value, upper Value) *ValueRange
- func (v *ValueRange) Bytes() []byte
- func (v *ValueRange) Compare(value Value) int
- func (v *ValueRange) Contains(value Value) bool
- func (v *ValueRange) Empty() bool
- func (v *ValueRange) HasLowerBound() bool
- func (v *ValueRange) HasUpperBound() bool
- func (v *ValueRange) LowerBoundType() BoundType
- func (v *ValueRange) LowerEndPoint() *EndPoint
- func (v *ValueRange) String() string
- func (v *ValueRange) UpperBoundType() BoundType
- func (v *ValueRange) UpperEndPoint() *EndPoint
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var BoundTypeNames = [...]string{
"BoundTypeOpen",
"BoundTypeClosed",
}
BoundTypeNames contains a dictionary of the names of BoundTypes.
var ValueTypeNames = [...]string{
"Int8ValueType",
"Int16ValueType",
"Int32ValueType",
"Int64ValueType",
"Uint8ValueType",
"Uint16ValueType",
"Uint32ValueType",
"Uint64ValueType",
}
ValueTypeNames contains a dictionary of the names of ValueTypes.
Functions ¶
This section is empty.
Types ¶
type BoundType ¶
type BoundType uint8
BoundType indicates whether an EndPoint of some ValueRange is contained in the ValueRange itself ("closed") or not ("open"). If a range is unbounded on a side, it is neither open nor closed on that side; the bound simply does not exist.
func BoundTypeFromBytes ¶
BoundTypeFromBytes unmarshals a BoundType from a sequence of bytes.
func BoundTypeFromMarshalUtil ¶
func BoundTypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (boundType BoundType, err error)
BoundTypeFromMarshalUtil unmarshals a BoundType using a MarshalUtil (for easier unmarshaling).
type EndPoint ¶
type EndPoint struct {
// contains filtered or unexported fields
}
EndPoint contains information about where ValueRanges start and end. It combines a threshold value with a BoundType.
func EndPointFromBytes ¶
EndPointFromBytes unmarshals an EndPoint from a sequence of bytes.
func EndPointFromMarshalUtil ¶
func EndPointFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (endPoint *EndPoint, err error)
EndPointFromMarshalUtil unmarshals an EndPoint using a MarshalUtil (for easier unmarshaling).
func NewEndPoint ¶
NewEndPoint create a new EndPoint from the given details.
type Int16Value ¶
type Int16Value int16
Int16Value is a wrapper for int16 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Int16ValueFromBytes ¶
func Int16ValueFromBytes(bytes []byte) (int16Value Int16Value, consumedBytes int, err error)
Int16ValueFromBytes unmarshals a Int16Value from a sequence of bytes.
func Int16ValueFromMarshalUtil ¶
func Int16ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int16Value Int16Value, err error)
Int16ValueFromMarshalUtil unmarshals an Int16Value using a MarshalUtil (for easier unmarshaling).
func (Int16Value) Bytes ¶
func (i Int16Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Int16Value) Compare ¶
func (i Int16Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Int16Value) String ¶
func (i Int16Value) String() string
String returns a human readable version of the Value.
func (Int16Value) Type ¶
func (i Int16Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Int32Value ¶
type Int32Value int32
Int32Value is a wrapper for int32 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Int32ValueFromBytes ¶
func Int32ValueFromBytes(bytes []byte) (int32Value Int32Value, consumedBytes int, err error)
Int32ValueFromBytes unmarshals a Int32Value from a sequence of bytes.
func Int32ValueFromMarshalUtil ¶
func Int32ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int32Value Int32Value, err error)
Int32ValueFromMarshalUtil unmarshals an Int32Value using a MarshalUtil (for easier unmarshaling).
func (Int32Value) Bytes ¶
func (i Int32Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Int32Value) Compare ¶
func (i Int32Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Int32Value) String ¶
func (i Int32Value) String() string
String returns a human readable version of the Value.
func (Int32Value) Type ¶
func (i Int32Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Int64Value ¶
type Int64Value int64
Int64Value is a wrapper for int64 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Int64ValueFromBytes ¶
func Int64ValueFromBytes(bytes []byte) (int64Value Int64Value, consumedBytes int, err error)
Int64ValueFromBytes unmarshals a Int64Value from a sequence of bytes.
func Int64ValueFromMarshalUtil ¶
func Int64ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int64Value Int64Value, err error)
Int64ValueFromMarshalUtil unmarshals an Int64Value using a MarshalUtil (for easier unmarshaling).
func (Int64Value) Bytes ¶
func (i Int64Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Int64Value) Compare ¶
func (i Int64Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Int64Value) String ¶
func (i Int64Value) String() string
String returns a human readable version of the Value.
func (Int64Value) Type ¶
func (i Int64Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Int8Value ¶
type Int8Value int8
Int8Value is a wrapper for int8 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Int8ValueFromBytes ¶
Int8ValueFromBytes unmarshals a Int8Value from a sequence of bytes.
func Int8ValueFromMarshalUtil ¶
func Int8ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int8Value Int8Value, err error)
Int8ValueFromMarshalUtil unmarshals an Int8Value using a MarshalUtil (for easier unmarshaling).
func (Int8Value) Compare ¶
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
type Uint16Value ¶
type Uint16Value uint16
Uint16Value is a wrapper for uint16 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Uint16ValueFromBytes ¶
func Uint16ValueFromBytes(bytes []byte) (uint16Value Uint16Value, consumedBytes int, err error)
Uint16ValueFromBytes unmarshals a Uint16Value from a sequence of bytes.
func Uint16ValueFromMarshalUtil ¶
func Uint16ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint16Value Uint16Value, err error)
Uint16ValueFromMarshalUtil unmarshals an Uint16Value using a MarshalUtil (for easier unmarshaling).
func (Uint16Value) Bytes ¶
func (i Uint16Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Uint16Value) Compare ¶
func (i Uint16Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Uint16Value) String ¶
func (i Uint16Value) String() string
String returns a human readable version of the Value.
func (Uint16Value) Type ¶
func (i Uint16Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Uint32Value ¶
type Uint32Value uint32
Uint32Value is a wrapper for uint32 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Uint32ValueFromBytes ¶
func Uint32ValueFromBytes(bytes []byte) (uint32Value Uint32Value, consumedBytes int, err error)
Uint32ValueFromBytes unmarshals a Uint32Value from a sequence of bytes.
func Uint32ValueFromMarshalUtil ¶
func Uint32ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint32Value Uint32Value, err error)
Uint32ValueFromMarshalUtil unmarshals an Uint32Value using a MarshalUtil (for easier unmarshaling).
func (Uint32Value) Bytes ¶
func (i Uint32Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Uint32Value) Compare ¶
func (i Uint32Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Uint32Value) String ¶
func (i Uint32Value) String() string
String returns a human readable version of the Value.
func (Uint32Value) Type ¶
func (i Uint32Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Uint64Value ¶
type Uint64Value uint64
Uint64Value is a wrapper for uint64 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Uint64ValueFromBytes ¶
func Uint64ValueFromBytes(bytes []byte) (uint64Value Uint64Value, consumedBytes int, err error)
Uint64ValueFromBytes unmarshals a Uint64Value from a sequence of bytes.
func Uint64ValueFromMarshalUtil ¶
func Uint64ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint64Value Uint64Value, err error)
Uint64ValueFromMarshalUtil unmarshals an Uint64Value using a MarshalUtil (for easier unmarshaling).
func (Uint64Value) Bytes ¶
func (i Uint64Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Uint64Value) Compare ¶
func (i Uint64Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Uint64Value) String ¶
func (i Uint64Value) String() string
String returns a human readable version of the Value.
func (Uint64Value) Type ¶
func (i Uint64Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Uint8Value ¶
type Uint8Value uint8
Uint8Value is a wrapper for uint8 values that makes these values compatible with the Value interface so they can be used in ValueRanges.
func Uint8ValueFromBytes ¶
func Uint8ValueFromBytes(bytes []byte) (uint8Value Uint8Value, consumedBytes int, err error)
Uint8ValueFromBytes unmarshals a Uint8Value from a sequence of bytes.
func Uint8ValueFromMarshalUtil ¶
func Uint8ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint8Value Uint8Value, err error)
Uint8ValueFromMarshalUtil unmarshals an Uint8Value using a MarshalUtil (for easier unmarshaling).
func (Uint8Value) Bytes ¶
func (i Uint8Value) Bytes() []byte
Bytes returns a marshaled version of the Value.
func (Uint8Value) Compare ¶
func (i Uint8Value) Compare(other Value) int
Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller.
func (Uint8Value) String ¶
func (i Uint8Value) String() string
String returns a human readable version of the Value.
func (Uint8Value) Type ¶
func (i Uint8Value) Type() ValueType
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
type Value ¶
type Value interface { // Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code. Type() ValueType // Compare return 0 if the other Value is identical, -1 if it is bigger and 1 if it is smaller. Compare(other Value) int // Bytes returns a marshaled version of the Value. Bytes() []byte // String returns a human readable version of the Value. String() string }
Value is an interface that is used by the ValueRanges to compare different Values. It is required to keep the ValueRange generic.
func ValueFromBytes ¶
ValueFromBytes unmarshals a Value from a sequence of bytes.
func ValueFromMarshalUtil ¶
func ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (value Value, err error)
ValueFromMarshalUtil unmarshals a Value using a MarshalUtil (for easier unmarshaling).
type ValueRange ¶
type ValueRange struct {
// contains filtered or unexported fields
}
ValueRange defines the boundaries around a contiguous span of Values (i.e. "integers from 1 to 100 inclusive").
It is not possible to iterate over the contained values. Each Range may be bounded or unbounded. If bounded, there is an associated endpoint value and the range is considered to be either open (does not include the endpoint) or closed (includes the endpoint) on that side.
With three possibilities on each side, this yields nine basic types of ranges, enumerated below:
Notation Definition Factory method (a .. b) {x | a < x < b} Open [a .. b] {x | a <= x <= b} Closed (a .. b] {x | a < x <= b} OpenClosed [a .. b) {x | a <= x < b} ClosedOpen (a .. +INF) {x | x > a} GreaterThan [a .. +INF) {x | x >= a} AtLeast (-INF .. b) {x | x < b} LessThan (-INF .. b] {x | x <= b} AtMost (-INF .. +INF) {x} All
When both endpoints exist, the upper endpoint may not be less than the lower. The endpoints may be equal only if at least one of the bounds is closed.
func AtLeast ¶
func AtLeast(lower Value) *ValueRange
AtLeast returns a ValueRange that contains all Values greater than or equal to lower.
func AtMost ¶
func AtMost(upper Value) *ValueRange
AtMost returns a ValueRange that contains all Values less than or equal to upper.
func Closed ¶
func Closed(lower Value, upper Value) *ValueRange
Closed returns a ValueRange that contains all Values greater than or equal to lower and less than or equal to upper.
func ClosedOpen ¶
func ClosedOpen(lower Value, upper Value) *ValueRange
ClosedOpen returns a ValueRange that contains all Values greater than or equal to lower and strictly less than upper.
func FromBytes ¶
func FromBytes(valueRangeBytes []byte) (valueRange *ValueRange, consumedBytes int, err error)
FromBytes unmarshals a ValueRange from a sequence of bytes.
func FromMarshalUtil ¶
func FromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (valueRange *ValueRange, err error)
FromMarshalUtil unmarshals a ValueRange using a MarshalUtil (for easier unmarshaling).
func GreaterThan ¶
func GreaterThan(lower Value) *ValueRange
GreaterThan returns a ValueRange that contains all Values strictly greater than lower.
func LessThan ¶
func LessThan(upper Value) *ValueRange
LessThan returns a ValueRange that contains all values strictly less than upper.
func Open ¶
func Open(lower Value, upper Value) *ValueRange
Open returns a ValueRange that contains all Values strictly greater than lower and strictly less than upper.
func OpenClosed ¶
func OpenClosed(lower Value, upper Value) *ValueRange
OpenClosed returns a ValueRange that contains all values strictly greater than lower and less than or equal to upper.
func (*ValueRange) Bytes ¶
func (v *ValueRange) Bytes() []byte
Bytes returns a marshaled version of the ValueRange.
func (*ValueRange) Compare ¶
func (v *ValueRange) Compare(value Value) int
Compare returns 0 if the ValueRange contains the given Value, -1 if its contained Values are smaller and 1 if they are bigger.
func (*ValueRange) Contains ¶
func (v *ValueRange) Contains(value Value) bool
Contains returns true if value is within the bounds of this ValueRange.
func (*ValueRange) Empty ¶
func (v *ValueRange) Empty() bool
Empty returns true if this range is of the form [v..v) or (v..v]. This does not encompass ranges of the form (v..v), because such ranges are invalid and can't be constructed at all.
Note that certain discrete ranges such as the integer range (3..4) are not considered empty, even though they contain no actual values.
func (*ValueRange) HasLowerBound ¶
func (v *ValueRange) HasLowerBound() bool
HasLowerBound returns true if this ValueRange has a lower EndPoint.
func (*ValueRange) HasUpperBound ¶
func (v *ValueRange) HasUpperBound() bool
HasUpperBound returns true if this ValueRange has an upper EndPoint.
func (*ValueRange) LowerBoundType ¶
func (v *ValueRange) LowerBoundType() BoundType
LowerBoundType returns the type of this ValueRange's lower bound - BoundTypeClosed if the range includes its lower EndPoint and BoundTypeOpen if it does not include its lower EndPoint.
func (*ValueRange) LowerEndPoint ¶
func (v *ValueRange) LowerEndPoint() *EndPoint
LowerEndPoint returns the lower EndPoint of this ValueRange. It panics if the ValueRange has no lower EndPoint.
func (*ValueRange) String ¶
func (v *ValueRange) String() string
String returns a human readable version of the ValueRange.
func (*ValueRange) UpperBoundType ¶
func (v *ValueRange) UpperBoundType() BoundType
UpperBoundType returns the type of this ValueRange's upper bound - BoundTypeClosed if the range includes its upper EndPoint and BoundTypeOpen if it does not include its upper EndPoint.
func (*ValueRange) UpperEndPoint ¶
func (v *ValueRange) UpperEndPoint() *EndPoint
UpperEndPoint returns the upper EndPoint of this Range or nil if it is unbounded.
type ValueType ¶
type ValueType int8
ValueType represents the type different kinds of Values.
const ( // Int8ValueType represents the type of Int8Values. Int8ValueType ValueType = iota // Int16ValueType represents the type of Int16Values. Int16ValueType // Int32ValueType represents the type of Int32Values. Int32ValueType // Int64ValueType represents the type of Int64Values. Int64ValueType // Uint8ValueType represents the type of Uint8Values. Uint8ValueType // Uint16ValueType represents the type of Uint16ValueType. Uint16ValueType // Uint32ValueType represents the type of Uint32ValueType. Uint32ValueType // Uint64ValueType represents the type of Uint64Values. Uint64ValueType )
func ValueTypeFromBytes ¶
ValueTypeFromBytes unmarshals a ValueType from a sequence of bytes.
func ValueTypeFromMarshalUtil ¶
func ValueTypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (valueType ValueType, err error)
ValueTypeFromMarshalUtil unmarshals a ValueType using a MarshalUtil (for easier unmarshaling).