本文整理汇总了Golang中github.com/corestoreio/csfw/util.Int64Slice类的典型用法代码示例。如果您正苦于以下问题:Golang Int64Slice类的具体用法?Golang Int64Slice怎么用?Golang Int64Slice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Int64Slice类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestInt64SliceMap
func TestInt64SliceMap(t *testing.T) {
af := func(i int64) int64 {
return i + 1
}
l := util.Int64Slice{2, 4, 30, 22}
assert.EqualValues(t, []int64{3, 5, 31, 23}, l.Map(af).ToInt64())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:7,代码来源:int64_slice_test.go
示例2: TestInt64SliceAny
func TestInt64SliceAny(t *testing.T) {
l := util.Int64Slice{33, 44, 55, 66}
assert.True(t, l.Any(func(i int64) bool {
return i == 44
}))
assert.False(t, l.Any(func(i int64) bool {
return i == 77
}))
}
开发者ID:joao-parana,项目名称:csfw,代码行数:9,代码来源:int64_slice_test.go
示例3: IDs
// IDs returns an Int64Slice with all store ids
func (s GroupSlice) IDs() util.Int64Slice {
if len(s) == 0 {
return nil
}
var ids util.Int64Slice
for _, g := range s {
if g != nil {
ids.Append(g.Data.GroupID)
}
}
return ids
}
开发者ID:joao-parana,项目名称:csfw,代码行数:13,代码来源:group.go
示例4: IDs
// IDs returns an Int64Slice with all store ids
func (ss StoreSlice) IDs() util.Int64Slice {
if len(ss) == 0 {
return nil
}
var ids util.Int64Slice
for _, st := range ss {
if st != nil {
ids.Append(st.Data.StoreID)
}
}
return ids
}
开发者ID:joao-parana,项目名称:csfw,代码行数:13,代码来源:store.go
示例5: IDs
// IDs returns an Int64Slice with all website ids
func (ws WebsiteSlice) IDs() util.Int64Slice {
if len(ws) == 0 {
return nil
}
var ids util.Int64Slice
for _, w := range ws {
if w != nil {
ids.Append(w.Data.WebsiteID)
}
}
return ids
}
开发者ID:joao-parana,项目名称:csfw,代码行数:13,代码来源:website.go
示例6: findHandlerByID
// findHandlerByID returns the Handler for the searchID. If not found
// or slices have an indifferent length or something is nil it will
// return the DefaultErrorHandler.
func findHandlerByID(so scope.Scope, id int64, idsIdx util.Int64Slice, handlers []ctxhttp.HandlerFunc) ctxhttp.HandlerFunc {
if len(idsIdx) != len(handlers) {
return DefaultAlternativeHandler
}
index := idsIdx.Index(id)
if index < 0 {
return DefaultAlternativeHandler
}
prospect := handlers[index]
if nil == prospect {
return DefaultAlternativeHandler
}
if PkgLog.IsInfo() {
PkgLog.Info("geoip.findHandlerByID.found", "scope", so.String(), "id", id, "idsIdx", idsIdx)
}
return prospect
}
开发者ID:joao-parana,项目名称:csfw,代码行数:22,代码来源:service.go
示例7: TestInt64SliceReduce
func TestInt64SliceReduce(t *testing.T) {
af := func(i int64) bool {
return (i & 1) == 1
}
l := util.Int64Slice{2, 4, 30, 22}
assert.EqualValues(t, []int64{}, l.Reduce(af).ToInt64())
l.Append(3, 5)
assert.EqualValues(t, []int64{3, 5}, l.Reduce(af).ToInt64())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:9,代码来源:int64_slice_test.go
示例8: TestInt64SliceAll
func TestInt64SliceAll(t *testing.T) {
af := func(i int64) bool {
return (i & 1) == 0
}
l := util.Int64Slice{2, 4, 30, 22}
assert.True(t, l.All(af))
l.Append(11)
assert.False(t, l.All(af))
}
开发者ID:joao-parana,项目名称:csfw,代码行数:9,代码来源:int64_slice_test.go
示例9: TestInt64SliceSum
func TestInt64SliceSum(t *testing.T) {
l := util.Int64Slice{2, 4, 30, 22}
assert.EqualValues(t, 58, l.Sum())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:4,代码来源:int64_slice_test.go
示例10: TestInt64SliceInclude
func TestInt64SliceInclude(t *testing.T) {
is := util.Int64Slice{-29, 30, -1}
assert.True(t, is.Include(-1))
assert.False(t, is.Include(-100))
}
开发者ID:joao-parana,项目名称:csfw,代码行数:5,代码来源:int64_slice_test.go
示例11: TestInt64SliceIndex
func TestInt64SliceIndex(t *testing.T) {
is := util.Int64Slice{-29, 30, -1}
assert.EqualValues(t, 2, is.Index(-1))
assert.EqualValues(t, -1, is.Index(123))
}
开发者ID:joao-parana,项目名称:csfw,代码行数:5,代码来源:int64_slice_test.go
示例12: TestInt64SliceDelete
func TestInt64SliceDelete(t *testing.T) {
is := util.Int64Slice{-29, 30, -1}
assert.NoError(t, is.Delete(1))
assert.EqualValues(t, []int64{-29, -1}, is.ToInt64())
assert.EqualError(t, util.ErrOutOfRange, is.Delete(100).Error())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:6,代码来源:int64_slice_test.go
示例13: TestInt64SliceUpdate
func TestInt64SliceUpdate(t *testing.T) {
is := util.Int64Slice{-29, 30, -1}
assert.NoError(t, is.Update(1, 31))
assert.EqualValues(t, 31, is[1])
assert.EqualError(t, util.ErrOutOfRange, is.Update(100, 2).Error())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:6,代码来源:int64_slice_test.go
示例14: TestInt64SliceAppend
func TestInt64SliceAppend(t *testing.T) {
is := util.Int64Slice{30, -1}
is.Append(6)
assert.EqualValues(t, []int64{30, -1, 6}, is.ToInt64())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:5,代码来源:int64_slice_test.go
示例15: TestInt64SliceSort
func TestInt64SliceSort(t *testing.T) {
is := util.Int64Slice{100, 10, 3, 20, 9, 30, -1}
assert.EqualValues(t, []int64{-1, 3, 9, 10, 20, 30, 100}, is.Sort().ToInt64())
assert.EqualValues(t, []int64{100, 30, 20, 10, 9, 3, -1}, is.Reverse().ToInt64())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:5,代码来源:int64_slice_test.go
示例16: TestInt64SliceUnique
func TestInt64SliceUnique(t *testing.T) {
l := util.Int64Slice{30, 2, 4, 30, 2, 22}
assert.EqualValues(t, []int64{30, 2, 4, 22}, l.Unique().ToInt64())
}
开发者ID:joao-parana,项目名称:csfw,代码行数:4,代码来源:int64_slice_test.go
注:本文中的github.com/corestoreio/csfw/util.Int64Slice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论