Documentation ¶
Index ¶
Constants ¶
const ( OKCode int = iota DupKeysCode EmptyEnumCode IdxRangeCode MultiElemsCode MultiMatchCode NegCountCode NilAccCode NilCmpCode NilEnumCode NilEqCode NilKeyCode NilLessCode NilPredCode NilSelCode NoMatchCode NotSameTypeCode StrtCntRangeCode WrongTypeCode )
linq-related error codes
Variables ¶
var ( ErrDupKeys = &Error{code: DupKeysCode, msg: "duplicate keys"} ErrEmptyEnum = &Error{code: EmptyEnumCode, msg: "enum is empty"} ErrIdxRange = &Error{code: IdxRangeCode, msg: "index is out of range"} ErrMultiElems = &Error{code: MultiElemsCode, msg: "enum contains multiple elements"} ErrMultiMatch = &Error{code: MultiMatchCode, msg: "enum contains multiple matching elements"} ErrNegCount = &Error{code: NegCountCode, msg: "count is negative"} ErrNilAcc = &Error{code: NilAccCode, msg: "accumulator is nil"} ErrNilCmp = &Error{code: NilCmpCode, msg: "comparison is nil"} ErrNilEnum = &Error{code: NilEnumCode, msg: "enum is nil"} ErrNilEq = &Error{code: NilEqCode, msg: "equality is nil"} ErrNilKey = &Error{code: NilKeyCode, msg: "key is nil"} ErrNilLess = &Error{code: NilLessCode, msg: "less is nil"} ErrNilPred = &Error{code: NilPredCode, msg: "predicate is nil"} ErrNilSel = &Error{code: NilSelCode, msg: "selector is nil"} ErrNoMatch = &Error{code: NoMatchCode, msg: "no items match the predicate"} ErrStrtCntRange = &Error{code: StrtCntRangeCode, msg: "start and/or count are out of range"} )
linq-related errors.
var CaseInsensitiveCmp = func(e1, e2 Elem) int { s1 := strings.ToLower(e1.(string)) s2 := strings.ToLower(e2.(string)) if s1 < s2 { return -1 } if s1 > s2 { return +1 } return 0 }
CaseInsensitiveCmp is a case-insensitive Comparison for strings.
var CaseInsensitiveEq = func(e1, e2 Elem) bool { return strings.ToLower(e1.(string)) == strings.ToLower(e2.(string)) }
CaseInsensitiveEq is a case-insensitive Equality for strings.
var Identity = func(el Elem) Elem {
return el
}
Identity is an identity selector.
Functions ¶
This section is empty.
Types ¶
type Comparison ¶
Comparison compares two Elems and returns negative if the first Elem is less than the second one, zero if the first Elem is equal to the second one and positive if the first Elem is greater than the second one (see https://docs.microsoft.com/dotnet/api/system.comparison-1).
func LessToComparison ¶
func LessToComparison(ls Less) Comparison
LessToComparison converts Less to Comparison.
type DeEnum ¶
type DeEnum struct {
// contains filtered or unexported fields
}
DeEnum is a sequence of Elems with stop field.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents linq error and implements Errorer interface.
func NotSameTypeError ¶
NotSameTypeError erroneous situation elems have not same type.
func WrongTypeError ¶
WrongTypeError denotes erroneous situation when Elem has wrong type.
type Errorer ¶
Errorer interface identifies a linq error. All errors returned by linq package implement Errorer interface.
type PredicateIdx ¶
PredicateIdx projects an element and its index into bool.
type SelectorIdx ¶
SelectorIdx projects an element and its index into another element.