• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang functional.Count函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/keep94/gofunctional3/functional.Count函数的典型用法代码示例。如果您正苦于以下问题:Golang Count函数的具体用法?Golang Count怎么用?Golang Count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Count函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestAppendTo2

func TestAppendTo2(t *testing.T) {
	values := []int{1, 2}
	c := AppendTo(&values)
	stream := functional.Slice(functional.Count(), 3, 7)
	doConsume(t, c, stream, nil)
	stream = functional.Slice(functional.Count(), 7, 11)
	doConsume(t, c, stream, nil)
	verifyValues(t, values, 1, 11)
	if actual := cap(values); actual != 11 {
		t.Errorf("Expected capacity of 11, got %v", actual)
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:12,代码来源:consume_test.go


示例2: TestAppendTo

func TestAppendTo(t *testing.T) {
	var values []int
	stream := functional.Slice(functional.Count(), 0, 7)
	doConsume(t, AppendTo(&values), stream, nil)
	verifyValues(t, values, 0, 7)
	if actual := cap(values); actual != 15 {
		t.Errorf("Expected capacity of 15, got %v", actual)
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:9,代码来源:consume_test.go


示例3: TestGrowingBufferBig

func TestGrowingBufferBig(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 4)
	b := NewGrowingBuffer(intSlice, 5)
	doConsume(t, b, stream, nil)
	verifyFetched(t, b, 0, 4)
	if actual := cap(b.Values().([]int)); actual != 6 {
		t.Errorf("Expected capacity of 6, got %v", actual)
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:9,代码来源:consume_test.go


示例4: TestPtrGrowingBuffer2

func TestPtrGrowingBuffer2(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 6)
	b := NewPtrGrowingBuffer(intPtrSlice, 0, intCreater)
	doConsume(t, b, stream, nil)
	verifyPtrFetched(t, b, 0, 6)
	if actual := cap(b.Values().([]*int)); actual != 7 {
		t.Errorf("Expected capacity of 7, got %v", actual)
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:9,代码来源:consume_test.go


示例5: ExampleAppendTo

func ExampleAppendTo() {
	values := []int{5}
	stream := functional.Slice(functional.Count(), 0, 2)
	AppendTo(&values).Consume(stream)
	for i := range values {
		fmt.Println(values[i])
	}
	// Output:
	// 5
	// 0
	// 1
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:12,代码来源:consume_test.go


示例6: ExampleAppendPtrsTo

func ExampleAppendPtrsTo() {
	var values []*int
	stream := functional.Slice(functional.Count(), 0, 3)
	AppendPtrsTo(&values, nil).Consume(stream)
	for i := range values {
		fmt.Println(*values[i])
	}
	// Output:
	// 0
	// 1
	// 2
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:12,代码来源:consume_test.go


示例7: TestAppendPtrsTo2

func TestAppendPtrsTo2(t *testing.T) {
	var values []*int
	stream := functional.Slice(functional.Count(), 0, 3)
	var x int
	// Our creater returns a pointer to the same variable.
	creater := func() interface{} {
		return &x
	}
	doConsume(t, AppendPtrsTo(&values, creater), stream, nil)
	// We should have a slice of length 3 with all pointers being the same.
	if len(values) != 3 || values[0] != values[1] || values[0] != values[2] {
		t.Error("Failure")
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:14,代码来源:consume_test.go


示例8: TestPtrGrowingBufferPointersPreserved

func TestPtrGrowingBufferPointersPreserved(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 3)
	b := NewPtrGrowingBuffer(intPtrSlice, 4, nil)
	b.Consume(stream)
	values := b.Values().([]*int)
	zeroToThree := make([]*int, len(values))
	copy(zeroToThree, values)

	stream = functional.Slice(functional.Count(), 10, 15)
	b.Consume(stream)
	values = b.Values().([]*int)
	tenToFifteen := make([]*int, len(values))
	copy(tenToFifteen, values)

	stream = functional.Slice(functional.Count(), 20, 22)
	b.Consume(stream)
	values = b.Values().([]*int)
	twentyToTwentyTwo := make([]*int, len(values))
	copy(twentyToTwentyTwo, values)

	verifyPtrValues(t, zeroToThree, 0, 3)
	verifyPtrValues(t, tenToFifteen, 10, 15)
	verifyPtrValues(t, twentyToTwentyTwo, 20, 22)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:24,代码来源:consume_test.go


示例9: TestPtrBufferWithCreater

func TestPtrBufferWithCreater(t *testing.T) {
	stream := functional.Count()
	aslice := make([]*int, 5)
	for i := range aslice {
		aslice[i] = new(int)
	}
	origSlice := make([]*int, len(aslice))
	copy(origSlice, aslice)
	b := NewPtrBuffer(aslice)
	doConsume(t, b, stream, nil)
	verifyPtrFetched(t, b, 0, 5)
	for i := range aslice {
		if origSlice[i] != aslice[i] {
			t.Fatal("Expect aslice pointers not to change.")
		}
	}
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:17,代码来源:consume_test.go


示例10: TestPageBufferSecondPage

func TestPageBufferSecondPage(t *testing.T) {
	stream := functional.Count()
	pb := NewPageBuffer(make([]int, 6), 1)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 3, 6, 1, false)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例11: TestBufferBig

func TestBufferBig(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 4)
	b := NewBuffer(make([]int, 5))
	doConsume(t, b, stream, nil)
	verifyFetched(t, b, 0, 4)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例12: TestPageBufferParitalFirst

func TestPageBufferParitalFirst(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 1)
	pb := NewPageBuffer(make([]int, 6), 0)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 0, 1, 0, true)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例13: TestPageBufferFullSecond

func TestPageBufferFullSecond(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 6)
	pb := NewPageBuffer(make([]int, 6), 1)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 3, 6, 1, true)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例14: TestPageBufferEmptyThirdTooHigh

func TestPageBufferEmptyThirdTooHigh(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 6)
	pb := NewPageBuffer(make([]int, 6), 3)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 3, 6, 1, true)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例15: TestPageBufferParitalThirdToHigh

func TestPageBufferParitalThirdToHigh(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 7)
	pb := NewPageBuffer(make([]int, 6), 3)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 6, 7, 2, true)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例16: TestPageBufferNegativePage

func TestPageBufferNegativePage(t *testing.T) {
	stream := functional.Count()
	pb := NewPageBuffer(make([]int, 6), -1)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 0, 3, 0, false)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例17: TestPtrGrowingBuffer

func TestPtrGrowingBuffer(t *testing.T) {
	stream := functional.Slice(functional.Count(), 0, 6)
	b := NewPtrGrowingBuffer(intPtrSlice, 5, nil)
	doConsume(t, b, stream, nil)
	verifyPtrFetched(t, b, 0, 6)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例18: TestPtrBuffer

func TestPtrBuffer(t *testing.T) {
	stream := functional.Count()
	b := NewPtrBuffer(make([]*int, 5))
	doConsume(t, b, stream, nil)
	verifyPtrFetched(t, b, 0, 5)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例19: TestPtrPageBuffer

func TestPtrPageBuffer(t *testing.T) {
	stream := functional.Count()
	pb := NewPtrPageBuffer(make([]*int, 6), 0)
	doConsume(t, pb, stream, nil)
	verifyPtrPageFetched(t, pb, 0, 3, 0, false)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go


示例20: TestPageBufferThirdPage

func TestPageBufferThirdPage(t *testing.T) {
	stream := functional.Count()
	pb := NewPageBuffer(make([]int, 6), 2)
	doConsume(t, pb, stream, nil)
	verifyPageFetched(t, pb, 6, 9, 2, false)
}
开发者ID:keep94,项目名称:gofunctional3,代码行数:6,代码来源:consume_test.go



注:本文中的github.com/keep94/gofunctional3/functional.Count函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang vsafe.User类代码示例发布时间:2022-05-23
下一篇:
Golang functional.Stream类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap