示例#1
0
func Sort(p uint) bool {
	n := uint64(1 << p)
	increasing := &Increasing{}
	funnelsort.NewItem = newItem
	funnelsort.FunnelSort(&Random{n}, increasing)
	return increasing.outOfOrder
}
示例#2
0
文件: tweet.go 项目: eikeon/tweet
func Sort(r io.Reader, w TweetWriter) {
	runtime.GOMAXPROCS(runtime.NumCPU())

	funnelsort.NewItem = NewItem

	br := bufio.NewReaderSize(r, 1<<24)
	in := NewTweetReader(br)
	funnelsort.FunnelSort(in, w)
}
示例#3
0
func TestFunnelSort(t *testing.T) {
	n := uint64(1 << 14)
	increasing := &Increasing{}
	funnelsort.NewItem = newItem
	funnelsort.FunnelSort(&Random{n}, increasing)

	if increasing.outOfOrder {
		t.Error("output not sorted")
		t.FailNow()
	}
}