cloudflared/vendor/github.com/golang-collections/collections/collections.go
2018-07-19 15:02:24 -05:00

28 lines
431 B
Go

package collections
type (
Collection interface {
Do(func(interface{})bool)
}
)
func GetRange(c Collection, start, length int) []interface{} {
end := start + length
items := make([]interface{}, length)
i := 0
j := 0
c.Do(func(item interface{})bool{
if i >= start {
if i < end {
items[j] = item
j++
} else {
return false
}
}
i++
return true
})
return items[:j]
}