scheduler: Adding SetLimit to LimitIterator
This commit is contained in:
parent
5afa7e4681
commit
e804567324
|
@ -19,6 +19,10 @@ func NewLimitIterator(ctx Context, source RankIterator, limit int) *LimitIterato
|
|||
return iter
|
||||
}
|
||||
|
||||
func (iter *LimitIterator) SetLimit(limit int) {
|
||||
iter.limit = limit
|
||||
}
|
||||
|
||||
func (iter *LimitIterator) Next() *RankedNode {
|
||||
if iter.seen == iter.limit {
|
||||
return nil
|
||||
|
|
|
@ -24,7 +24,8 @@ func TestLimitIterator(t *testing.T) {
|
|||
}
|
||||
static := NewStaticRankIterator(ctx, nodes)
|
||||
|
||||
limit := NewLimitIterator(ctx, static, 2)
|
||||
limit := NewLimitIterator(ctx, static, 1)
|
||||
limit.SetLimit(2)
|
||||
|
||||
out := collectRanked(limit)
|
||||
if len(out) != 2 {
|
||||
|
|
Loading…
Reference in New Issue