當前位置: 首頁>>代碼示例>>Golang>>正文


Golang util.Int64Slice類代碼示例

本文整理匯總了Golang中github.com/corestoreio/csfw/util.Int64Slice的典型用法代碼示例。如果您正苦於以下問題:Golang Int64Slice類的具體用法?Golang Int64Slice怎麽用?Golang Int64Slice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Int64Slice類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/corestoreio/csfw/util.Int64Slice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。