Documentation
¶
Index ¶
- Variables
- func AddOne(ex int) int
- func AssertFalse(t *testing.T, got bool)
- func AssertTrue(t *testing.T, got bool)
- func ListOrderedKinds() []string
- func Max[T Ordered](a, b T) T
- func Min[T Ordered](a, b T) T
- func MinMax[T Ordered](a, b T) (T, T)
- func MyFuncAny(ex any) any
- func MyFuncInt(ex int) int
- func PrintExample[T any](ex T)
- func RandomNumber[T Number]() T
- func RandomNumberList[T IntType](n int) []T
- func Scale[E IntType](s []E, c E) []E
- func SmallIntList(n int) []int
- func TryMapping1()
- type AllOrdered
- type Comparable
- type Example
- type ExampleMap
- type FloatLister
- type FloatStringer
- type FloatType
- type IExample
- type IExampleMap
- type IntType
- type KindInfo
- type Number
- type Ordered
- type Sort
- type Stack
- type Stringable
- type UintType
Constants ¶
This section is empty.
Variables ¶
View Source
var Mapping2 = ExampleMap[any]{ "any": MyFuncAny, "a": anything{"stuff"}.ExampleFunc, "fake": func(ex any) any { return "fake" }, }
Mapping2 maps string names to examples. The examples are stored as functions with the signature
func(ex T) T
which is instantiated to
func(ex any) any
in this example
Functions ¶
func AssertFalse ¶
func AssertTrue ¶
func ListOrderedKinds ¶
func ListOrderedKinds() []string
func PrintExample ¶
func PrintExample[T any](ex T)
func RandomNumber ¶
func RandomNumber[T Number]() T
func RandomNumberList ¶
func SmallIntList ¶
func TryMapping1 ¶
func TryMapping1()
Types ¶
type AllOrdered ¶
All Ordered types string int, int16, int32, int64, int8 uint, uint16, uint32, uint64, uint8 float32, float64 uintptr
type Comparable ¶
type Comparable interface {
comparable
}
type ExampleMap ¶
type FloatLister ¶
type FloatStringer ¶
Reference: https://codilime.com/blog/generics-in-go-definition-history-and-examples-of-use/
type IExampleMap ¶
type Sort ¶
type Sort interface {
// Len is the number of elements in the collection.
Len() int
// Less reports whether the element with index i
// must sort before the element with index j.
//
// If both Less(i, j) and Less(j, i) are false,
// then the elements at index i and j are considered equal.
// Sort may place equal elements in any order in the final result,
// while Stable preserves the original input order of equal elements.
//
// Less must describe a transitive ordering:
// - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well.
// - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well.
//
// Note that floating-point comparison (the < operator on float32 or float64 values)
// is not a transitive ordering when not-a-number (NaN) values are involved.
// See Float64Slice.Less for a correct implementation for floating-point values.
Less(i, j int) bool
// Swap swaps the elements with indexes i and j.
Swap(i, j int)
}
An implementation of Interface can be sorted by the routines in this package. The methods refer to elements of the underlying collection by integer index.
type Stringable ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example
command
|
|
|
examples/addone
command
|
|
|
examples/genericfunc
command
|
|
|
examples/escapes
command
|
|
|
examples/gitit
command
|
|
|
gnuflags
standard command line flags based on GNU standards.
|
standard command line flags based on GNU standards. |
|
package main contains a Response to Stack Overflow question 71677581
|
package main contains a Response to Stack Overflow question 71677581 |
|
71677581
package main contains a Response to Stack Overflow question 71677581
|
package main contains a Response to Stack Overflow question 71677581 |
|
Package sort provides a generic implementation of the standard library sort package primitives for sorting slices and user-defined collections.
|
Package sort provides a generic implementation of the standard library sort package primitives for sorting slices and user-defined collections. |
Click to show internal directories.
Click to hide internal directories.