You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
386 B

package coll
type Iterator[T any] Vector[T]
func (i Iterator[T]) ForEach(f func(int, T)) {
for index := 0; index < i.length; index++ {
f(index, i.array[index])
}
}
func (i Iterator[T]) ForBreak(f func(index int, t T, breaker func())) {
var broke bool
brk := func() {
broke = true
}
for index := 0; index < i.length || !broke; index++ {
f(index, i.array[index], brk)
}
}