open-nomad/nomad/state/iterator.go
2023-04-10 15:36:59 +00:00

35 lines
545 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package state
type SliceIterator struct {
data []interface{}
idx int
}
func NewSliceIterator() *SliceIterator {
return &SliceIterator{
data: []interface{}{},
idx: 0,
}
}
func (i *SliceIterator) Add(datum interface{}) {
i.data = append(i.data, datum)
}
func (i *SliceIterator) Next() interface{} {
if i.idx == len(i.data) {
return nil
}
datum := i.data[i.idx]
i.idx += 1
return datum
}
func (i *SliceIterator) WatchCh() <-chan struct{} {
return nil
}