Documentation
¶
Index ¶
- type AbsCollection
- func (arr *AbsCollection) Append(item interface{}) ICollection
- func (arr *AbsCollection) Avg() IMix
- func (arr *AbsCollection) Contains(obj interface{}) bool
- func (arr *AbsCollection) Count() int
- func (arr *AbsCollection) DD()
- func (arr *AbsCollection) Diff(arr2 ICollection) ICollection
- func (arr *AbsCollection) Each(f func(item interface{}, key int))
- func (arr *AbsCollection) Err() error
- func (arr *AbsCollection) Every(f func(item interface{}, key int) bool) bool
- func (arr *AbsCollection) Filter(f func(obj interface{}, index int) bool) ICollection
- func (arr *AbsCollection) First(f ...func(obj interface{}, index int) bool) IMix
- func (arr *AbsCollection) ForPage(page int, perPage int) ICollection
- func (arr *AbsCollection) Index(i int) IMix
- func (arr *AbsCollection) Insert(index int, obj interface{}) ICollection
- func (arr *AbsCollection) IsEmpty() bool
- func (arr *AbsCollection) IsNotEmpty() bool
- func (arr *AbsCollection) Join(split string, format ...func(item interface{}) string) string
- func (arr *AbsCollection) Last(fs ...func(item interface{}, key int) bool) IMix
- func (arr *AbsCollection) Map(f func(item interface{}, key int) interface{}) ICollection
- func (arr *AbsCollection) Max() IMix
- func (arr *AbsCollection) Median() IMix
- func (arr *AbsCollection) Merge(arr2 ICollection) ICollection
- func (arr *AbsCollection) Min() IMix
- func (arr *AbsCollection) Mode() IMix
- func (arr *AbsCollection) NewEmpty(err ...error) ICollection
- func (arr *AbsCollection) Nth(n int, offset int) ICollection
- func (arr *AbsCollection) Pad(count int, def interface{}) ICollection
- func (arr *AbsCollection) Pluck(key string) ICollection
- func (arr *AbsCollection) Pop() IMix
- func (arr *AbsCollection) Prepend(item interface{}) ICollection
- func (arr *AbsCollection) Push(item interface{}) ICollection
- func (arr *AbsCollection) Random() IMix
- func (arr *AbsCollection) Reduce(f func(carry IMix, item IMix) IMix) IMix
- func (arr *AbsCollection) Reject(f func(item interface{}, key int) bool) ICollection
- func (arr *AbsCollection) Remove(index int) ICollection
- func (arr *AbsCollection) Reverse() ICollection
- func (arr *AbsCollection) Search(item interface{}) int
- func (arr *AbsCollection) SetCompare(compare func(a interface{}, b interface{}) int) ICollection
- func (arr *AbsCollection) SetErr(err error) ICollection
- func (arr *AbsCollection) Shuffle() ICollection
- func (arr *AbsCollection) Slice(ps ...int) ICollection
- func (arr *AbsCollection) Sort() ICollection
- func (arr *AbsCollection) SortBy(key string) ICollection
- func (arr *AbsCollection) SortByDesc(key string) ICollection
- func (arr *AbsCollection) SortDesc() ICollection
- func (arr *AbsCollection) Sum() IMix
- func (arr *AbsCollection) ToFloat32s() ([]float32, error)
- func (arr *AbsCollection) ToFloat64s() ([]float64, error)
- func (arr *AbsCollection) ToInt64s() ([]int64, error)
- func (arr *AbsCollection) ToInts() ([]int, error)
- func (arr *AbsCollection) ToMixs() ([]IMix, error)
- func (arr *AbsCollection) ToStrings() ([]string, error)
- func (arr *AbsCollection) Unique() ICollection
- type Float32Collection
- func (arr *Float32Collection) Count() int
- func (arr *Float32Collection) DD()
- func (arr *Float32Collection) Index(i int) IMix
- func (arr *Float32Collection) Insert(index int, obj interface{}) ICollection
- func (arr *Float32Collection) NewEmpty(err ...error) ICollection
- func (arr *Float32Collection) Remove(i int) ICollection
- type Float64Collection
- func (arr *Float64Collection) Count() int
- func (arr *Float64Collection) DD()
- func (arr *Float64Collection) Index(i int) IMix
- func (arr *Float64Collection) Insert(index int, obj interface{}) ICollection
- func (arr *Float64Collection) NewEmpty(err ...error) ICollection
- func (arr *Float64Collection) Remove(i int) ICollection
- type ICollection
- type IMix
- type Int64Collection
- func (arr *Int64Collection) Count() int
- func (arr *Int64Collection) DD()
- func (arr *Int64Collection) Index(i int) IMix
- func (arr *Int64Collection) Insert(index int, obj interface{}) ICollection
- func (arr *Int64Collection) NewEmpty(err ...error) ICollection
- func (arr *Int64Collection) Remove(i int) ICollection
- type IntCollection
- type Mix
- func (m *Mix) Add(n IMix) (IMix, error)
- func (m *Mix) Compare(n IMix) (ret int, err error)
- func (m *Mix) DD()
- func (m *Mix) Div(n int) (IMix, error)
- func (m *Mix) Err() error
- func (m *Mix) Format() string
- func (m *Mix) Multi(n int) (IMix, error)
- func (m *Mix) SetErr(err error) IMix
- func (m *Mix) Sub(n IMix) (IMix, error)
- func (m *Mix) ToFloat32() (float32, error)
- func (m *Mix) ToFloat64() (float64, error)
- func (m *Mix) ToInt() (int, error)
- func (m *Mix) ToInt64() (int64, error)
- func (m *Mix) ToInterface() (interface{}, error)
- func (m *Mix) ToString() (string, error)
- func (m *Mix) Type() reflect.Type
- type ObjCollection
- func (arr *ObjCollection) Count() int
- func (arr *ObjCollection) DD()
- func (arr *ObjCollection) Index(i int) IMix
- func (arr *ObjCollection) Insert(index int, obj interface{}) ICollection
- func (arr *ObjCollection) NewEmpty(err ...error) ICollection
- func (arr *ObjCollection) Pluck(key string) ICollection
- func (arr *ObjCollection) Remove(i int) ICollection
- func (arr *ObjCollection) SortBy(key string) ICollection
- func (arr *ObjCollection) SortByDesc(key string) ICollection
- type StrCollection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbsCollection ¶
type AbsCollection struct { ICollection Parent ICollection //用于调用子类 // contains filtered or unexported fields }
这个是一个虚函数,能实现的都实现
func (*AbsCollection) Append ¶
func (arr *AbsCollection) Append(item interface{}) ICollection
func (*AbsCollection) Avg ¶
func (arr *AbsCollection) Avg() IMix
func (*AbsCollection) Contains ¶
func (arr *AbsCollection) Contains(obj interface{}) bool
func (*AbsCollection) Count ¶
func (arr *AbsCollection) Count() int
func (*AbsCollection) DD ¶
func (arr *AbsCollection) DD()
func (*AbsCollection) Diff ¶
func (arr *AbsCollection) Diff(arr2 ICollection) ICollection
func (*AbsCollection) Each ¶
func (arr *AbsCollection) Each(f func(item interface{}, key int))
func (*AbsCollection) Err ¶
func (arr *AbsCollection) Err() error
func (*AbsCollection) Every ¶
func (arr *AbsCollection) Every(f func(item interface{}, key int) bool) bool
func (*AbsCollection) Filter ¶
func (arr *AbsCollection) Filter(f func(obj interface{}, index int) bool) ICollection
func (*AbsCollection) First ¶
func (arr *AbsCollection) First(f ...func(obj interface{}, index int) bool) IMix
func (*AbsCollection) ForPage ¶
func (arr *AbsCollection) ForPage(page int, perPage int) ICollection
func (*AbsCollection) Index ¶
func (arr *AbsCollection) Index(i int) IMix
func (*AbsCollection) Insert ¶
func (arr *AbsCollection) Insert(index int, obj interface{}) ICollection
func (*AbsCollection) IsEmpty ¶
func (arr *AbsCollection) IsEmpty() bool
func (*AbsCollection) IsNotEmpty ¶
func (arr *AbsCollection) IsNotEmpty() bool
func (*AbsCollection) Join ¶
func (arr *AbsCollection) Join(split string, format ...func(item interface{}) string) string
func (*AbsCollection) Last ¶
func (arr *AbsCollection) Last(fs ...func(item interface{}, key int) bool) IMix
func (*AbsCollection) Map ¶
func (arr *AbsCollection) Map(f func(item interface{}, key int) interface{}) ICollection
func (*AbsCollection) Max ¶
func (arr *AbsCollection) Max() IMix
func (*AbsCollection) Median ¶
func (arr *AbsCollection) Median() IMix
func (*AbsCollection) Merge ¶
func (arr *AbsCollection) Merge(arr2 ICollection) ICollection
func (*AbsCollection) Min ¶
func (arr *AbsCollection) Min() IMix
func (*AbsCollection) Mode ¶
func (arr *AbsCollection) Mode() IMix
func (*AbsCollection) NewEmpty ¶
func (arr *AbsCollection) NewEmpty(err ...error) ICollection
下面的几个函数必须要实现
func (*AbsCollection) Nth ¶
func (arr *AbsCollection) Nth(n int, offset int) ICollection
func (*AbsCollection) Pad ¶
func (arr *AbsCollection) Pad(count int, def interface{}) ICollection
func (*AbsCollection) Pluck ¶
func (arr *AbsCollection) Pluck(key string) ICollection
func (*AbsCollection) Pop ¶
func (arr *AbsCollection) Pop() IMix
func (*AbsCollection) Prepend ¶
func (arr *AbsCollection) Prepend(item interface{}) ICollection
func (*AbsCollection) Push ¶
func (arr *AbsCollection) Push(item interface{}) ICollection
func (*AbsCollection) Random ¶
func (arr *AbsCollection) Random() IMix
func (*AbsCollection) Reduce ¶
func (arr *AbsCollection) Reduce(f func(carry IMix, item IMix) IMix) IMix
func (*AbsCollection) Reject ¶
func (arr *AbsCollection) Reject(f func(item interface{}, key int) bool) ICollection
func (*AbsCollection) Remove ¶
func (arr *AbsCollection) Remove(index int) ICollection
func (*AbsCollection) Reverse ¶
func (arr *AbsCollection) Reverse() ICollection
func (*AbsCollection) Search ¶
func (arr *AbsCollection) Search(item interface{}) int
func (*AbsCollection) SetCompare ¶
func (arr *AbsCollection) SetCompare(compare func(a interface{}, b interface{}) int) ICollection
func (*AbsCollection) SetErr ¶
func (arr *AbsCollection) SetErr(err error) ICollection
func (*AbsCollection) Shuffle ¶
func (arr *AbsCollection) Shuffle() ICollection
func (*AbsCollection) Slice ¶
func (arr *AbsCollection) Slice(ps ...int) ICollection
func (*AbsCollection) Sort ¶
func (arr *AbsCollection) Sort() ICollection
func (*AbsCollection) SortBy ¶
func (arr *AbsCollection) SortBy(key string) ICollection
func (*AbsCollection) SortByDesc ¶
func (arr *AbsCollection) SortByDesc(key string) ICollection
func (*AbsCollection) SortDesc ¶
func (arr *AbsCollection) SortDesc() ICollection
func (*AbsCollection) Sum ¶
func (arr *AbsCollection) Sum() IMix
func (*AbsCollection) ToFloat32s ¶
func (arr *AbsCollection) ToFloat32s() ([]float32, error)
func (*AbsCollection) ToFloat64s ¶
func (arr *AbsCollection) ToFloat64s() ([]float64, error)
func (*AbsCollection) ToInt64s ¶
func (arr *AbsCollection) ToInt64s() ([]int64, error)
func (*AbsCollection) ToInts ¶
func (arr *AbsCollection) ToInts() ([]int, error)
func (*AbsCollection) ToMixs ¶
func (arr *AbsCollection) ToMixs() ([]IMix, error)
func (*AbsCollection) ToStrings ¶
func (arr *AbsCollection) ToStrings() ([]string, error)
func (*AbsCollection) Unique ¶
func (arr *AbsCollection) Unique() ICollection
type Float32Collection ¶
type Float32Collection struct { AbsCollection // contains filtered or unexported fields }
func NewFloat32Collection ¶
func NewFloat32Collection(objs []float32) *Float32Collection
func (*Float32Collection) Count ¶
func (arr *Float32Collection) Count() int
func (*Float32Collection) DD ¶
func (arr *Float32Collection) DD()
func (*Float32Collection) Index ¶
func (arr *Float32Collection) Index(i int) IMix
func (*Float32Collection) Insert ¶
func (arr *Float32Collection) Insert(index int, obj interface{}) ICollection
func (*Float32Collection) NewEmpty ¶
func (arr *Float32Collection) NewEmpty(err ...error) ICollection
func (*Float32Collection) Remove ¶
func (arr *Float32Collection) Remove(i int) ICollection
type Float64Collection ¶
type Float64Collection struct { AbsCollection // contains filtered or unexported fields }
func NewFloat64Collection ¶
func NewFloat64Collection(objs []float64) *Float64Collection
func (*Float64Collection) Count ¶
func (arr *Float64Collection) Count() int
func (*Float64Collection) DD ¶
func (arr *Float64Collection) DD()
func (*Float64Collection) Index ¶
func (arr *Float64Collection) Index(i int) IMix
func (*Float64Collection) Insert ¶
func (arr *Float64Collection) Insert(index int, obj interface{}) ICollection
func (*Float64Collection) NewEmpty ¶
func (arr *Float64Collection) NewEmpty(err ...error) ICollection
func (*Float64Collection) Remove ¶
func (arr *Float64Collection) Remove(i int) ICollection
type ICollection ¶
type ICollection interface { // ICollection错误信息,链式调用的时候需要检查下这个error是否存在,每次调用之后都检查一下 Err() error // 设置ICollection的错误信息 SetErr(error) ICollection /* 下面的方法对所有Collection都生效 */ // 复制一份当前相同类型的ICollection结构,但是数据是空的 NewEmpty(err ...error) ICollection // 判断是否是空数组 IsEmpty() bool // 判断是否是空数组 IsNotEmpty() bool // 放入一个元素到数组中,对所有Collection生效, 仅当item和Collection结构不一致的时候返回错误 Append(item interface{}) ICollection // 删除一个元素, 需要自类实现 Remove(index int) ICollection // 增加一个元素。 Insert(index int, item interface{}) ICollection // 查找数据中是否包含,-1不包含,>=0 返回数组中元素下标,对所有Collection生效 Search(item interface{}) int // 过滤数组中重复的元素,仅对基础Collection生效 Unique() ICollection // 按照某个方法进行过滤, 保留符合的 Filter(func(item interface{}, key int) bool) ICollection // 按照某个方法进行过滤,去掉符合的 Reject(func(item interface{}, key int) bool) ICollection // 获取满足条件的第一个, 如果没有填写过滤条件,就获取所有的第一个 First(...func(item interface{}, key int) bool) IMix // 获取满足条件的最后一个,如果没有填写过滤条件,就获取所有的最后一个 Last(...func(item interface{}, key int) bool) IMix // 获取数组片段,对所有Collection生效 Slice(...int) ICollection // 获取某个下标,对所有Collection生效 Index(i int) IMix // 获取数组长度,对所有Collection生效 Count() int // 将两个数组进行合并,参数的数据挂在当前数组中,返回当前数组,对所有Collection生效 Merge(arr ICollection) ICollection // 每个元素都调用一次的方法 Each(func(item interface{}, key int)) // 每个元素都调用一次的方法, 并组成一个新的元素 Map(func(item interface{}, key int) interface{}) ICollection // 合并一些元素,并组成一个新的元素 Reduce(func(carry IMix, item IMix) IMix) IMix // 判断每个对象是否都满足, 如果collection是空,返回true Every(func(item interface{}, key int) bool) bool // 按照分页进行返回 ForPage(page int, perPage int) ICollection // 获取第n位值组成数组 Nth(n int, offset int) ICollection // 组成的个数 Pad(start int, def interface{}) ICollection // 从队列右侧弹出结构 Pop() IMix // 推入元素 Push(item interface{}) ICollection // 前面插入一个元素 Prepend(item interface{}) ICollection // 随机获取一个元素 Random() IMix // 倒置 Reverse() ICollection // 随机乱置 Shuffle() ICollection // 打印出当前数组结构 DD() /* 下面的方法对ObjCollection生效 */ // 返回数组中对象的某个key组成的数组,仅对ObjectCollection生效, key为对象属性名称,必须为public的属性 Pluck(key string) ICollection // 按照某个字段进行排序 SortBy(key string) ICollection // 按照某个字段进行排序,倒序 SortByDesc(key string) ICollection /* 下面的方法对基础Collection生效,但是ObjCollection一旦设置了Compare函数也生效 */ // 比较a和b,如果a>b, 返回1,如果a<b, 返回-1,如果a=b, 返回0 // 设置比较函数,理论上所有Collection都能设置比较函数,但是强烈不建议基础Collection设置 SetCompare(func(a interface{}, b interface{}) int) ICollection // 数组中最大的元素,仅对基础Collection生效, 可以传递一个比较函数 Max() IMix // 数组中最小的元素,仅对基础Collection生效 Min() IMix // 判断是否包含某个元素,(并不进行定位),对基础Collection生效 Contains(obj interface{}) bool // 比较两个数组,获取第一个数组不在第二个数组中的元素,组成新数组 Diff(arr ICollection) ICollection // 进行排序, 升序 Sort() ICollection // 进行排序,倒序 SortDesc() ICollection // 进行拼接 Join(split string, format ...func(item interface{}) string) string /* 下面的方法对基础Collection生效 */ // 获取平均值 Avg() IMix // 获取中位值 Median() IMix // 获取Mode值 Mode() IMix // 获取sum值 Sum() IMix /* 下面的方法对根据不同的对象,进行不同的调用转换 */ // 转化为golang原生的字符数组,仅对StrCollection生效 ToStrings() ([]string, error) // 转化为golang原生的Int64数组,仅对Int64Collection生效 ToInt64s() ([]int64, error) // 转化为golang原生的Int数组,仅对IntCollection生效 ToInts() ([]int, error) // 转化为obj数组 ToMixs() ([]IMix, error) // 转化为float64数组 ToFloat64s() ([]float64, error) // 转化为float32数组 ToFloat32s() ([]float32, error) }
ICollection表示数组结构,有几种类型
type IMix ¶
type IMix interface { Err() error SetErr(err error) IMix Compare(n IMix) (int, error) // 两个IMix结构是否相同 Type() reflect.Type // 获取类型 Add(mix IMix) (IMix, error) // 加法操作 Sub(mix IMix) (IMix, error) // 减法操作 Div(n int) (IMix, error) // 除法操作 Multi(n int) (IMix, error) // 乘法操作 ToString() (string, error) ToInt64() (int64, error) ToInt() (int, error) ToFloat64() (float64, error) ToFloat32() (float32, error) ToInterface() (interface{}, error) // 所有函数可用 Format() string // 打印成string DD() }
IMix是一个混合结构
type Int64Collection ¶
type Int64Collection struct { AbsCollection // contains filtered or unexported fields }
func NewInt64Collection ¶
func NewInt64Collection(objs []int64) *Int64Collection
func (*Int64Collection) Count ¶
func (arr *Int64Collection) Count() int
func (*Int64Collection) DD ¶
func (arr *Int64Collection) DD()
func (*Int64Collection) Index ¶
func (arr *Int64Collection) Index(i int) IMix
func (*Int64Collection) Insert ¶
func (arr *Int64Collection) Insert(index int, obj interface{}) ICollection
func (*Int64Collection) NewEmpty ¶
func (arr *Int64Collection) NewEmpty(err ...error) ICollection
func (*Int64Collection) Remove ¶
func (arr *Int64Collection) Remove(i int) ICollection
type IntCollection ¶
type IntCollection struct { AbsCollection // contains filtered or unexported fields }
func NewIntCollection ¶
func NewIntCollection(objs []int) *IntCollection
func (*IntCollection) Count ¶
func (arr *IntCollection) Count() int
func (*IntCollection) DD ¶
func (arr *IntCollection) DD()
func (*IntCollection) Index ¶
func (arr *IntCollection) Index(i int) IMix
func (*IntCollection) Insert ¶
func (arr *IntCollection) Insert(index int, obj interface{}) ICollection
func (*IntCollection) NewEmpty ¶
func (arr *IntCollection) NewEmpty(err ...error) ICollection
func (*IntCollection) Remove ¶
func (arr *IntCollection) Remove(i int) ICollection
type Mix ¶
type Mix struct { IMix // contains filtered or unexported fields }
func NewErrorMix ¶
func (*Mix) ToInterface ¶
type ObjCollection ¶
type ObjCollection struct { AbsCollection // contains filtered or unexported fields }
func NewObjCollectionByType ¶
func NewObjCollectionByType(typ reflect.Type) *ObjCollection
根据类型创建一个空的数组
func (*ObjCollection) Count ¶
func (arr *ObjCollection) Count() int
func (*ObjCollection) DD ¶
func (arr *ObjCollection) DD()
func (*ObjCollection) Index ¶
func (arr *ObjCollection) Index(i int) IMix
func (*ObjCollection) Insert ¶
func (arr *ObjCollection) Insert(index int, obj interface{}) ICollection
func (*ObjCollection) NewEmpty ¶
func (arr *ObjCollection) NewEmpty(err ...error) ICollection
func (*ObjCollection) Pluck ¶
func (arr *ObjCollection) Pluck(key string) ICollection
将对象的某个key作为Slice的value,作为slice返回
func (*ObjCollection) Remove ¶
func (arr *ObjCollection) Remove(i int) ICollection
func (*ObjCollection) SortByDesc ¶
func (arr *ObjCollection) SortByDesc(key string) ICollection
按照某个字段进行排序,倒序
type StrCollection ¶
type StrCollection struct { AbsCollection // contains filtered or unexported fields }
func NewStrCollection ¶
func NewStrCollection(objs []string) *StrCollection
func (*StrCollection) Count ¶
func (arr *StrCollection) Count() int
func (*StrCollection) DD ¶
func (arr *StrCollection) DD()
func (*StrCollection) Index ¶
func (arr *StrCollection) Index(i int) IMix
func (*StrCollection) Insert ¶
func (arr *StrCollection) Insert(index int, obj interface{}) ICollection
func (*StrCollection) NewEmpty ¶
func (arr *StrCollection) NewEmpty(err ...error) ICollection
func (*StrCollection) Remove ¶
func (arr *StrCollection) Remove(i int) ICollection
Click to show internal directories.
Click to hide internal directories.