Documentation ¶
Index ¶
- Constants
- type AnyType
- func (at AnyType) Float(fromVal any, toVal *float64) (err error)
- func (at AnyType) If(isTrue bool, trueValue, falseValue any) any
- func (at AnyType) InArray(item, stack any) bool
- func (at AnyType) Int(fromVal any, toVal *int) error
- func (at AnyType) Int64(fromVal any, toValue *int64) (err error)
- func (at AnyType) Int64Array(arr []any, dstArr *[]int64) error
- func (at AnyType) StructTo(src, dst any) error
- func (at AnyType) Uint(fromVal any, toVal *uint) error
- func (at AnyType) Uint64(fromVal any, toValue *uint64) (err error)
- func (at AnyType) Uint64Array(arr []any, dstArr *[]uint64) error
- type BoolType
- type FloatType
- func (ft FloatType) Abs(value float64) float64
- func (ft FloatType) ArrayAsc(arr []float64)
- func (ft FloatType) ArrayDesc(arr []float64)
- func (ft FloatType) Avg(values ...float64) float64
- func (ft FloatType) BinFind(value float64, arr []float64, isAsc bool) int
- func (ft FloatType) BinSearch(value float64, arr []float64, isAsc bool) int
- func (ft FloatType) Ceil(value float64) float64
- func (ft FloatType) Find(value float64, arr []float64) int
- func (ft FloatType) FindSorted(value float64, arr []float64, isAsc bool) int
- func (ft FloatType) Floor(value float64) float64
- func (ft FloatType) If(isTrue bool, trueValue, falseValue float64) float64
- func (ft FloatType) InArray(value float64, arr []float64) bool
- func (ft FloatType) InSortedArray(value float64, arr []float64, isAsc bool) bool
- func (ft FloatType) LoopFind(value float64, arr []float64) int
- func (ft FloatType) Max(values ...float64) float64
- func (ft FloatType) Min(values ...float64) float64
- func (ft FloatType) Round(value float64, places int) float64
- func (ft FloatType) SortAndBinSearch(value float64, arr []float64) int
- func (ft FloatType) Str(value float64) string
- func (ft FloatType) Sum(values ...float64) float64
- type IntType
- func (it IntType) Abs(value int64) int64
- func (it IntType) ArrayAsc(arr []int64)
- func (it IntType) ArrayDesc(arr []int64)
- func (it IntType) Avg(values ...int64) float64
- func (it IntType) BinFind(value int64, arr []int64, isAsc bool) int
- func (it IntType) BinSearch(value int64, arr []int64, isAsc bool) int
- func (it IntType) ConvertTo(from int64, toVal any) error
- func (it IntType) Find(value int64, arr []int64) int
- func (it IntType) FindSorted(value int64, arr []int64, isAsc bool) int
- func (it IntType) If(isTrue bool, trueValue, falseValue int64) int64
- func (it IntType) InArray(value int64, arr []int64) bool
- func (it IntType) InInt16Range(val int64) bool
- func (it IntType) InInt32Range(val int64) bool
- func (it IntType) InInt8Range(val int64) bool
- func (it IntType) InIntRange(val int64) bool
- func (it IntType) InRange(value, min, max int64) bool
- func (it IntType) InSortedArray(value int64, arr []int64, isAsc bool) bool
- func (it IntType) InUint16Range(val int64) bool
- func (it IntType) InUint32Range(val int64) bool
- func (it IntType) InUint64Range(val int64) bool
- func (it IntType) InUint8Range(val int64) bool
- func (it IntType) InUintRange(val int64) bool
- func (it IntType) IsEven(value int64) bool
- func (it IntType) IsOdd(value int64) bool
- func (it IntType) LoopFind(value int64, arr []int64) int
- func (it IntType) Max(values ...int64) int64
- func (it IntType) Min(values ...int64) int64
- func (it IntType) SortAndBinSearch(value int64, arr []int64) int
- func (it IntType) Str(value int64) string
- func (it IntType) Sum(values ...int64) int64
- type StrType
- func (st StrType) ArrayAsc(arr []string)
- func (st StrType) ArrayDesc(arr []string)
- func (st StrType) BinFind(value string, arr []string, isAsc bool) int
- func (st StrType) BinSearch(value string, arr []string, isAsc bool) int
- func (st StrType) Bool(str string, errBool bool) bool
- func (st StrType) Find(value string, arr []string) int
- func (st StrType) FindSorted(value string, arr []string, isAsc bool) int
- func (st StrType) Float(str string, errValue float64) float64
- func (st StrType) Format(format string, a ...any) string
- func (st StrType) HasPrefix(str, prefix string) bool
- func (st StrType) HasSuffix(str, suffix string) bool
- func (st StrType) If(boolValue bool, trueValue, falseValue string) string
- func (st StrType) InArray(value string, arr []string) bool
- func (st StrType) InSortedArray(value string, arr []string, isAsc bool) bool
- func (st StrType) Index(str, substr string) int
- func (st StrType) Int(str string, errValue int) int
- func (st StrType) IsEmpty(value string) bool
- func (st StrType) IsInt(str string) bool
- func (st StrType) IsNum(str string) bool
- func (st StrType) Join(strs []string, sep string) string
- func (st StrType) Len(str string) int
- func (st StrType) LoopFind(value string, arr []string) int
- func (st StrType) LowerFirst(str string) string
- func (st StrType) Ltrim(str, charsets string) string
- func (st StrType) Pint(str string, errValue uint) uint
- func (st StrType) Rand(length int) string
- func (st StrType) RandChars(chars string, length int) (str string)
- func (st StrType) RandLetters(length int) string
- func (st StrType) RandNumbers(length int) string
- func (st StrType) RegReplace(baseStr, regexpPattern, replacement string) string
- func (st StrType) Replace(str, old, new string, n int) string
- func (st StrType) Rtrim(str, charsets string) string
- func (st StrType) SortAndBinSearch(value string, arr []string) int
- func (st StrType) Split(str, sep string) []string
- func (st StrType) Sub(str string, begin, length int) string
- func (st StrType) Trim(str, charsets string) string
- func (st StrType) TrimSpace(str string) string
- func (st StrType) Uint(str string, errValue uint) uint
- func (st StrType) UpperFirst(str string) string
- type UintType
- func (ut UintType) ArrayAsc(arr []uint64)
- func (ut UintType) ArrayDesc(arr []uint64)
- func (ut UintType) Avg(values ...uint64) float64
- func (ut UintType) BinFind(value uint64, arr []uint64, isAsc bool) int
- func (ut UintType) BinSearch(value uint64, arr []uint64, isAsc bool) int
- func (ut UintType) ConvertTo(from uint64, toValue any) error
- func (ut UintType) Find(value uint64, arr []uint64) int
- func (ut UintType) FindSorted(value uint64, arr []uint64, isAsc bool) int
- func (ut UintType) If(isTrue bool, trueValue, falseValue uint64) uint64
- func (ut UintType) InArray(value uint64, arr []uint64) bool
- func (ut UintType) InRange(value, min, max uint64) bool
- func (ut UintType) InSortedArray(value uint64, arr []uint64, isAsc bool) bool
- func (ut UintType) IsEven(value uint64) bool
- func (ut UintType) IsOdd(value uint64) bool
- func (ut UintType) LoopFind(value uint64, arr []uint64) int
- func (ut UintType) Max(values ...uint64) uint64
- func (ut UintType) Min(values ...uint64) uint64
- func (ut UintType) SortAndBinSearch(value uint64, arr []uint64) int
- func (ut UintType) Str(value uint64) string
- func (ut UintType) Sum(values ...uint64) uint64
Constants ¶
const ( // 字母 + 数字,移除 il o0 CHARS string = `abcdefghjkmnpqrstuvwxyz123456789` // 纯字母,移除 il PURE_LETTER_CHARS string = `abcdefghjkmnopqrstuvwxyz` // 纯数字字符 PURE_NUMBER_CHARS string = `0123456789` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyType ¶
type AnyType struct{}
func (AnyType) Float ¶
Float 将 any 类型的值转换为 float64 类型的值。 支持以下类型:uint, uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, string(可以是浮点数字符串)。
func (AnyType) InArray ¶
Return true if stack has the element item, return false otherwise 由于使用了反射,可能在性能上有一定的负担,并且由于没有类型检查,不能有效地避免类型不匹配的情况 不推荐使用这种方式,请转换为具体类型后执行类型下的 InArray
func (AnyType) Int ¶
Int 将 any 类型的值转换为 int 类型的值。 支持以下类型:uint, uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, string(可以是 10 进制数字字符串)。
func (AnyType) Int64 ¶
Int64 将 any 类型的值转换为 int64 类型的值。 支持以下类型:uint, uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, string(可以是 10 进制数字字符串)。 注:float 类型转换时将损失精度,所以请传入 1111.0 这样不会损失精度的值
func (AnyType) Int64Array ¶
any 数组转为 int64 数组
func (AnyType) Uint ¶
Uint 将 any 类型的值转换为 uint 类型的值。 支持以下类型:uint, uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64, string(可以是 10 进制数字字符串)。
type FloatType ¶
type FloatType struct{}
func (FloatType) BinFind ¶
二分查找数组
此函数适用于数组值已排序或将对同一数组进行多次查找,传入已排序的数组以提高效率。 注:若传入未排序的数组,结果可能并不符合预期。
成功时返回查找到的数组下标,失败返回 -1
func (FloatType) Find ¶
查找数组 如果数组长度超过规定值,使用二分查找,否则使用遍历查找
二分查找时,将会对数组进行升序排序,查找成功返回的也会是升序后的下标
成功时返回查找到的数组下标,失败返回 -1
func (FloatType) InSortedArray ¶
已排序数组查找,threshold 参数生效
func (FloatType) LoopFind ¶
遍历查找数组
如果数组长度较长或对同一数组做多次 LoopFind,建议先 ArrayAsc 后使用 BinFind
成功时返回查找到的数组下标,失败返回 -1
func (FloatType) SortAndBinSearch ¶
对数组排序并进行二分查找法,成功返回查找到的数组下标,失败返回 -1
type IntType ¶
type IntType struct{}
func (IntType) BinFind ¶
二分查找数组
此函数适用于数组值已排序或将对同一数组进行多次查找,传入已排序的数组以提高效率。 注:若传入未排序的数组,结果可能并不符合预期。
成功时返回查找到的数组下标,失败返回 -1
func (IntType) ConvertTo ¶
将 int64 类型转换为 其他int 类型, 仅限int类型内转换
toVal 必须为 int相关类型的指针 eg.
var val int8 if err := ConvertTo(12, &val); err != nil {}
func (IntType) Find ¶
查找数组 如果数组长度超过规定值,使用二分查找,否则使用遍历查找
二分查找时,将会对数组进行升序排序,查找成功返回的也会是升序后的下标
成功时返回查找到的数组下标,失败返回 -1
func (IntType) InSortedArray ¶
已排序数组查找,threshold 参数生效
func (IntType) InUint16Range ¶
判断给定的整数是否在 uint16 范围内
func (IntType) InUint32Range ¶
判断给定的整数是否在 uint32 范围内
func (IntType) InUint64Range ¶
判断给定的整数是否在 uint64 范围内
func (IntType) LoopFind ¶
遍历查找数组
如果数组长度较长或对同一数组做多次 LoopFind,建议先 ArrayAsc 后使用 BinFind
成功时返回查找到的数组下标,失败返回 -1
func (IntType) SortAndBinSearch ¶
对数组排序并进行二分查找法,成功返回查找到的数组下标,失败返回 -1
type StrType ¶
type StrType struct{}
func (StrType) BinFind ¶
二分查找数组
此函数适用于数组值已排序或将对同一数组进行多次查找,传入已排序的数组以提高效率。 注:若传入未排序的数组,结果可能并不符合预期。
成功时返回查找到的数组下标,失败返回 -1
func (StrType) Find ¶
查找数组 如果数组长度超过规定值,使用二分查找,否则使用遍历查找
二分查找时,将会对数组进行升序排序,查找成功返回的也会是升序后的下标
成功时返回查找到的数组下标,失败返回 -1
func (StrType) Float ¶
Covert string to positive int using strconv.Atoi(), return errValue if err != nil or value <= 0
func (StrType) If ¶
Return string param trueValue if boolValue=true, return string param falseValue otherwise
func (StrType) InSortedArray ¶
已排序数组查找,threshold 参数生效
func (StrType) LoopFind ¶
遍历查找数组
如果数组长度较长或对同一数组做多次 LoopFind,建议先 ArrayAsc 后使用 BinFind
成功时返回查找到的数组下标,失败返回 -1
func (StrType) Pint ¶
Covert string to positive int using strconv.Atoi(), return errValue if err != nil or value <= 0
func (StrType) RandLetters ¶
Generate random str base on letter chars
func (StrType) RandNumbers ¶
Generate random str base on number chars
func (StrType) RegReplace ¶
Replace baseStr with regexpPattern to replacement
func (StrType) SortAndBinSearch ¶
对数组排序并进行二分查找法,成功返回查找到的数组下标,失败返回 -1
type UintType ¶
type UintType struct{}
func (UintType) BinFind ¶
二分查找数组
此函数适用于数组值已排序或将对同一数组进行多次查找,传入已排序的数组以提高效率。 注:若传入未排序的数组,结果可能并不符合预期。
成功时返回查找到的数组下标,失败返回 -1
func (UintType) ConvertTo ¶
将 uint64 类型转换为 其他int 类型, 仅限int类型内转换
toValue 必须为 int相关类型的指针 eg.
var val int8 if err := ConvertTo(12, &val); err != nil {}
func (UintType) Find ¶
查找数组 如果数组长度超过规定值,使用二分查找,否则使用遍历查找
二分查找时,将会对数组进行升序排序,查找成功返回的也会是升序后的下标
成功时返回查找到的数组下标,失败返回 -1
func (UintType) InSortedArray ¶
已排序数组查找,threshold 参数生效
func (UintType) LoopFind ¶
遍历查找数组
如果数组长度较长或对同一数组做多次 LoopFind,建议先 ArrayAsc 后使用 BinFind
成功时返回查找到的数组下标,失败返回 -1
func (UintType) SortAndBinSearch ¶
对数组排序(不会改变原数组顺序)并进行二分查找法,成功返回查找到的数组下标,失败返回 -1