func TestDistinct(t *testing.T) {
	var pb PriorityBitmap
	pb.Set(0, 0)
	pb.Set(1, 1)
	assert.EqualValues(t, []interface{}{0, 1}, itertools.IterableAsSlice(&pb))
	pb.Set(0, -1)
	assert.EqualValues(t, []interface{}{0, 1}, itertools.IterableAsSlice(&pb))
	pb.Set(1, -2)
	assert.EqualValues(t, []interface{}{1, 0}, itertools.IterableAsSlice(&pb))
}
func TestIntBounds(t *testing.T) {
	var pb PriorityBitmap
	pb.Set(math.MaxInt32, math.MinInt32)
	pb.Set(math.MinInt32, math.MaxInt32)
	assert.EqualValues(t, []interface{}{math.MaxInt32, math.MinInt32}, itertools.IterableAsSlice(&pb))
}
示例#3
0
func bitmapSlice(bm *Bitmap) (ret []int) {
	sl := itertools.IterableAsSlice(bm)
	missinggo.CastSlice(&ret, sl)
	return
}