Documentation ¶
Index ¶
- Constants
- func AppendInt(dst []byte, i int64, base int) []byte
- func AppendUint(dst []byte, i uint64, base int) []byte
- func Atoi(s string) (int, error)
- func BoolToDigit[T ~bool, D digit.Digit](v T) D
- func BoolsToDigits[T ~bool, D digit.Digit](a []T) (b []D)
- func DereferenceImplementType(v reflect.Value) reflect.Type
- func DereferenceInterfaceValue(v reflect.Value) reflect.Value
- func DereferencePtrValue(v reflect.Value) reflect.Value
- func DereferenceSlice(v reflect.Value) reflect.Value
- func DereferenceType(t reflect.Type) reflect.Type
- func DereferenceValue(v reflect.Value) reflect.Value
- func DigitToDigit[T digit.Digit, D digit.Digit](v T) (D, error)
- func DigitToFloat64[T digit.Digit](v T) float64
- func DigitsToDigits[T digit.Digit, D digit.Digit](a []T) (b []D, err error)
- func FormatInt(i int64, base int) string
- func FormatUint(i uint64, base int) string
- func FormatUintByDict(dict []byte, num uint64) string
- func IndirectValue(v reflect.Value) reflect.Value
- func InitBool(p *bool, def bool) (done bool)
- func InitByte(p *byte, def byte) (done bool)
- func InitFloat32(p *float32, def float32) (done bool)
- func InitFloat64(p *float64, def float64) (done bool)
- func InitInt(p *int, def int) (done bool)
- func InitInt16(p *int16, def int16) (done bool)
- func InitInt32(p *int32, def int32) (done bool)
- func InitInt64(p *int64, def int64) (done bool)
- func InitInt8(p *int8, def int8) (done bool)
- func InitPointer(v reflect.Value) (done bool)
- func InitSampleValue(t reflect.Type, maxNestingDeep int) reflect.Value
- func InitString(p *string, def string) (done bool)
- func InitUint(p *uint, def uint) (done bool)
- func InitUint16(p *uint16, def uint16) (done bool)
- func InitUint32(p *uint32, def uint32) (done bool)
- func InitUint64(p *uint64, def uint64) (done bool)
- func InitUint8(p *uint8, def uint8) (done bool)
- func Itoa(i int) string
- func ParseInt(s string, base int, bitSize int) (i int64, err error)
- func ParseUint(s string, base int, bitSize int) (uint64, error)
- func ParseUintByDict[D digit.Digit](dict []byte, numStr string) (D, error)
- func ReferenceSlice(v reflect.Value, ptrDepth int) reflect.Value
- func ReferenceType(t reflect.Type, ptrDepth int) reflect.Type
- func ReferenceValue(v reflect.Value, ptrDepth int) reflect.Value
- func RuntimeTypeID(t reflect.Type) uintptr
- func RuntimeTypeIDOf(i interface{}) uintptr
- func SetsDifference[T comparable](set1, set2 []T, others ...[]T) []T
- func SetsIntersect[T comparable](set1, set2 []T, others ...[]T) []T
- func SetsUnion[T comparable](set1, set2 []T, others ...[]T) []T
- func StringToDigit[T ~string, D digit.Digit](v T, base int, bitSize int) (D, error)
- func StringsToDigits[T ~string, D digit.Digit](a []T, base int, bitSize int) (b []D, err error)
- func ToBool[T ~string | digit.Digit](v T) bool
- func ToBools[T ~string | digit.Digit](a []T) []bool
- func ToInterface(v interface{}) interface{}
- func ToInterfaces[T any](a []T) []interface{}
- func ToPtr[T any](v T) *T
- func ToPtrWithErr[T any](v T, err error) (*T, error)
- func ToString[T ~string](v interface{}) T
- func ToStrings[T any, D ~string](a []T) []D
- func UnsafeBytesToString(b []byte) string
- func UnsafeStringToBytes(s string) []byte
- func VecConcat[T any](s ...[]T) []T
- func VecCopy[T any](s []T) []T
- func VecCopyWithin[T any](s []T, target, start int, end ...int)
- func VecDistinct[T comparable](s *[]T, changeSlice bool) (distinctCount map[T]int)
- func VecEvery[T any](s []T, fn func(s []T, k int, v T) bool) bool
- func VecFill[T any](s []T, value T, start int, end ...int)
- func VecFilter[T any](s []T, fn func(s []T, k int, v T) bool) []T
- func VecFind[T any](s []T, fn func(s []T, k int, v T) bool) (k int, v T)
- func VecIncludes[T comparable](s []T, valueToFind T, fromIndex ...int) bool
- func VecIndexOf[T comparable](s []T, searchElement T, fromIndex ...int) int
- func VecIntersect[T comparable](s ...[]T) (intersectCount map[T]int)
- func VecLastIndexOf[T comparable](s []T, searchElement T, fromIndex ...int) int
- func VecMap[T any](s []T, fn func(s []T, k int, v T) T) []T
- func VecOne[T any](s []T) T
- func VecPop[T any](s *[]T) (T, bool)
- func VecPush[T any](s *[]T, element ...T) int
- func VecPushDistinct[T comparable](s []T, element ...T) []T
- func VecReduce[T any](s []T, fn func(s []T, k int, v, accumulator T) T, initialValue ...T) T
- func VecReduceRight[T any](s []T, fn func(s []T, k int, v, accumulator T) T, initialValue ...T) T
- func VecRemoveEvery[T comparable](p *[]T, elements ...T) int
- func VecRemoveFirst[T comparable](p *[]T, elements ...T) int
- func VecReverse[T any](s []T)
- func VecShift[T any](s *[]T) (T, bool)
- func VecSlice[T any](s []T, begin int, end ...int) []T
- func VecSome[T any](s []T, fn func(s []T, k int, v T) bool) bool
- func VecSplice[T any](s *[]T, start, deleteCount int, items ...T)
- func VecUnshift[T any](s *[]T, element ...T) int
- func VecUnshiftDistinct[T comparable](s *[]T, element ...T) int
- func Zero[T any]() T
- type Value
Constants ¶
const ( Host64bit = strconv.IntSize == 64 Host32bit = ^uint(0)>>32 == 0 )
Variables ¶
This section is empty.
Functions ¶
func AppendInt ¶
AppendInt appends the string form of the integer i, as generated by FormatInt, to dst and returns the extended buffer. NOTE:
Compatible with standard package strconv.
func AppendUint ¶
AppendUint appends the string form of the unsigned integer i, as generated by FormatUint, to dst and returns the extended buffer. NOTE:
Compatible with standard package strconv.
func BoolToDigit ¶
BoolToDigit converts bool to digit.
func BoolsToDigits ¶
func DereferenceImplementType ¶
DereferenceImplementType returns the underlying type of the value that implements the interface v.
func DereferenceInterfaceValue ¶
DereferenceInterfaceValue returns the value of the underlying type that implements the interface v.
func DereferencePtrValue ¶
DereferencePtrValue returns the underlying non-pointer type value.
func DereferenceSlice ¶
DereferenceSlice convert []*D to []D.
func DereferenceType ¶
DereferenceType dereference, get the underlying non-pointer type.
func DereferenceValue ¶
DereferenceValue dereference and unpack interface, get the underlying non-pointer and non-interface value.
func DigitToFloat64 ¶
DigitToFloat64 converts digit to float64.
func DigitsToDigits ¶
DigitsToDigits creates a copy of the digit slice.
func FormatInt ¶
FormatInt returns the string representation of i in the given base, for 2 <= base <= 62. NOTE:
Compatible with standard package strconv.
func FormatUint ¶
FormatUint returns the string representation of i in the given base, for 2 <= base <= 62. NOTE:
Compatible with standard package strconv.
func FormatUintByDict ¶
FormatUintByDict convert num into corresponding string according to dict.
func IndirectValue ¶
IndirectValue gets the indirect value.
func InitFloat32 ¶
InitFloat32 initializes zero float32 pointer with def.
func InitFloat64 ¶
InitFloat64 initializes zero float64 pointer with def.
func InitPointer ¶
InitPointer initializes nil pointer with zero value.
func InitSampleValue ¶
InitSampleValue initialize the given type with some non-zero value( "?", $max_number, 0.1, true)
func InitString ¶
InitString initializes empty string pointer with def.
func InitUint16 ¶
InitUint16 initializes zero uint16 pointer with def.
func InitUint32 ¶
InitUint32 initializes zero uint32 pointer with def.
func InitUint64 ¶
InitUint64 initializes zero uint64 pointer with def.
func Itoa ¶
Itoa is equivalent to FormatInt(int64(i), 10). NOTE:
Compatible with standard package strconv.
func ParseInt ¶
ParseInt interprets a string s in the given base (0, 2 to 62) and bit size (0 to 64) and returns the corresponding value i.
If base == 0, the base is implied by the string's prefix: base 2 for "0b", base 8 for "0" or "0o", base 16 for "0x", and base 10 otherwise. Also, for base == 0 only, underscore characters are permitted per the Go integer literal syntax. If base is below 0, is 1, or is above 62, an error is returned.
The bitSize argument specifies the integer type that the result must fit into. Bit sizes 0, 8, 16, 32, and 64 correspond to int, int8, int16, int32, and int64. If bitSize is below 0 or above 64, an error is returned.
The errors that ParseInt returns have concrete type *NumError and include err.Num = s. If s is empty or contains invalid digits, err.Err = ErrSyntax and the returned value is 0; if the value corresponding to s cannot be represented by a signed integer of the given size, err.Err = ErrRange and the returned value is the maximum magnitude integer of the appropriate bitSize and sign. NOTE:
Compatible with standard package strconv.
func ParseUint ¶
ParseUint is like ParseInt but for unsigned numbers. NOTE:
Compatible with standard package strconv.
func ParseUintByDict ¶
ParseUintByDict convert numStr into corresponding uint64 according to dict.
func ReferenceSlice ¶
ReferenceSlice convert []D to []*D, the ptrDepth is the count of '*'.
func ReferenceType ¶
ReferenceType convert D to *D, the ptrDepth is the count of '*'.
func ReferenceValue ¶
ReferenceValue convert D to *D, the ptrDepth is the count of '*'.
func RuntimeTypeID ¶
RuntimeTypeID returns the underlying type ID in current runtime from reflect.Type. NOTE:
*A and A returns the different runtime type ID; It is 10 times performance of t.String().
func RuntimeTypeIDOf ¶
func RuntimeTypeIDOf(i interface{}) uintptr
RuntimeTypeIDOf returns the underlying type ID in current runtime from interface object. NOTE:
*A and A returns the different runtime type ID; It is 10 times performance of t.String().
func SetsDifference ¶
func SetsDifference[T comparable](set1, set2 []T, others ...[]T) []T
SetsDifference calculates between multiple collections: set1 - set2 - others... This method does not change the existing slices, but instead returns a new slice.
func SetsIntersect ¶
func SetsIntersect[T comparable](set1, set2 []T, others ...[]T) []T
SetsIntersect calculates between multiple collections: set1 ∩ set2 ∩ others... This method does not change the existing slices, but instead returns a new slice.
func SetsUnion ¶
func SetsUnion[T comparable](set1, set2 []T, others ...[]T) []T
SetsUnion calculates between multiple collections: set1 ∪ set2 ∪ others... This method does not change the existing slices, but instead returns a new slice.
func StringToDigit ¶
StringToDigit converts ~string to digit. If base == 0, the base is implied by the string's prefix: base 2 for "0b", base 8 for "0" or "0o", base 16 for "0x", and base 10 otherwise. Also, for base == 0 only, underscore characters are permitted per the Go integer literal syntax. If base is below 0, is 1, or is above 62, an error is returned.
func StringsToDigits ¶
func ToInterface ¶
func ToInterface(v interface{}) interface{}
ToInterface converts any to interface.
func ToInterfaces ¶
func ToInterfaces[T any](a []T) []interface{}
ToInterfaces converts []any to []interface.
func ToPtrWithErr ¶
ToPtrWithErr converts D to *D.
func UnsafeBytesToString ¶
UnsafeBytesToString convert []byte type to string type.
func UnsafeStringToBytes ¶
UnsafeStringToBytes convert string type to []byte type. NOTE:
panic if modify the member value of the []byte.
func VecConcat ¶
func VecConcat[T any](s ...[]T) []T
VecConcat is used to merge two or more slices. This method does not change the existing slices, but instead returns a new slice.
func VecCopyWithin ¶
VecCopyWithin copies part of an slice to another location in the current slice. @target
Zero-based index at which to copy the sequence to. If negative, target will be counted from the end.
@start
Zero-based index at which to start copying elements from. If negative, start will be counted from the end.
@end
Zero-based index at which to end copying elements from. VecCopyWithin copies up to but not including end. If negative, end will be counted from the end. If end is omitted, VecCopyWithin will copy until the last index (default to len(s)).
func VecDistinct ¶
func VecDistinct[T comparable](s *[]T, changeSlice bool) (distinctCount map[T]int)
VecDistinct calculates the count of each different element, and only saves these different elements in place if changeSlice is true.
func VecEvery ¶
VecEvery tests whether all elements in the slice pass the test implemented by the provided function. NOTE:
Calling this method on an empty slice will return true for any condition!
func VecFill ¶
VecFill changes all elements in the current slice to a value, from a start index to an end index. @value
Zero-based index at which to copy the sequence to. If negative, target will be counted from the end.
@start
Zero-based index at which to start copying elements from. If negative, start will be counted from the end.
@end
Zero-based index at which to end copying elements from. VecCopyWithin copies up to but not including end. If negative, end will be counted from the end. If end is omitted, VecCopyWithin will copy until the last index (default to len(s)).
func VecFilter ¶
VecFilter creates a new slice with all elements that pass the test implemented by the provided function.
func VecFind ¶
VecFind returns the key-value of the first element in the provided slice that satisfies the provided testing function. NOTE:
If not found, k = -1
func VecIncludes ¶
func VecIncludes[T comparable](s []T, valueToFind T, fromIndex ...int) bool
VecIncludes determines whether an slice includes a certain value among its entries. @fromIndex
The index to start the search at. Defaults to 0.
func VecIndexOf ¶
func VecIndexOf[T comparable](s []T, searchElement T, fromIndex ...int) int
VecIndexOf returns the first index at which a given element can be found in the slice, or -1 if it is not present. @fromIndex
The index to start the search at. Defaults to 0.
func VecIntersect ¶
func VecIntersect[T comparable](s ...[]T) (intersectCount map[T]int)
VecIntersect calculates intersection of two or more slices, and returns the count of each element.
func VecLastIndexOf ¶
func VecLastIndexOf[T comparable](s []T, searchElement T, fromIndex ...int) int
VecLastIndexOf returns the last index at which a given element can be found in the slice, or -1 if it is not present. @fromIndex
The index to start the search at. Defaults to 0.
func VecMap ¶
VecMap creates a new slice populated with the results of calling a provided function on every element in the calling slice.
func VecOne ¶
func VecOne[T any](s []T) T
VecOne try to return the first element, otherwise return zero value.
func VecPop ¶
VecPop removes the last element from an slice and returns that element. This method changes the length of the slice.
func VecPush ¶
VecPush adds one or more elements to the end of an slice and returns the new length of the slice.
func VecPushDistinct ¶
func VecPushDistinct[T comparable](s []T, element ...T) []T
VecPushDistinct adds one or more new elements that do not exist in the current slice at the end.
func VecReduce ¶
VecReduce executes a reducer function (that you provide) on each element of the slice, resulting in a single output value. @accumulator
The accumulator accumulates callback's return values. It is the accumulated value previously returned in the last invocation of the callback—or initialValue, if it was supplied (see below).
@initialValue
A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first element in the slice will be used and skipped.
func VecReduceRight ¶
VecReduceRight applies a function against an accumulator and each value of the slice (from right-to-left) to reduce it to a single value. @accumulator
The accumulator accumulates callback's return values. It is the accumulated value previously returned in the last invocation of the callback—or initialValue, if it was supplied (see below).
@initialValue
A value to use as the first argument to the first call of the callback. If no initialValue is supplied, the first element in the slice will be used and skipped.
func VecRemoveEvery ¶
func VecRemoveEvery[T comparable](p *[]T, elements ...T) int
VecRemoveEvery removes all the elements from the slice, and returns the new length of the slice.
func VecRemoveFirst ¶
func VecRemoveFirst[T comparable](p *[]T, elements ...T) int
VecRemoveFirst removes the first matched elements from the slice, and returns the new length of the slice.
func VecShift ¶
VecShift removes the first element from an slice and returns that removed element. This method changes the length of the slice.
func VecSlice ¶
VecSlice returns a copy of a portion of an slice into a new slice object selected from begin to end (end not included) where begin and end represent the index of items in that slice. The original slice will not be modified.
func VecSome ¶
VecSome tests whether at least one element in the slice passes the test implemented by the provided function. NOTE:
Calling this method on an empty slice returns false for any condition!
func VecSplice ¶
VecSplice changes the contents of an slice by removing or replacing existing elements and/or adding new elements in place.
func VecUnshift ¶
VecUnshift adds one or more elements to the beginning of an slice and returns the new length of the slice.
func VecUnshiftDistinct ¶
func VecUnshiftDistinct[T comparable](s *[]T, element ...T) int
VecUnshiftDistinct adds one or more new elements that do not exist in the current slice to the beginning and returns the new length of the slice.
Types ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value go underlying type data
func ValueFrom2 ¶
ValueFrom2 gets go underlying type data from *reflect.Value.
func (Value) CanAddr ¶
CanAddr reports whether the value's address can be obtained with Addr. Such values are called addressable. A value is addressable if it is an element of a slice, an element of an addressable array, a field of an addressable struct, or the result of dereferencing a pointer.
func (Value) Elem ¶
Elem returns the Value that the interface i contains or that the pointer i points to.
func (Value) FuncForPC ¶
FuncForPC returns a *Func describing the function that contains the given program counter address, or else nil.
If pc represents multiple functions because of inlining, it returns the a *Func describing the innermost function, but with an entry of the outermost function.
NOTE: Its kind must be a reflect.Func, otherwise it returns nil
func (Value) RuntimeTypeID ¶
RuntimeTypeID gets the underlying type ID in current runtime. NOTE:
*A and A gets the different runtime type ID; It is 10 times performance of reflect.TypeOf(i).String().
func (Value) UnderlyingElem ¶
UnderlyingElem returns the underlying Value that the interface i contains or that the pointer i points to.