Skip to content

Instantly share code, notes, and snippets.

@icholy
Created September 18, 2025 18:41
Show Gist options
  • Select an option

  • Save icholy/f2d83673f3477780661c66e21cb426f9 to your computer and use it in GitHub Desktop.

Select an option

Save icholy/f2d83673f3477780661c66e21cb426f9 to your computer and use it in GitHub Desktop.
package main
type btreeIter[T any] struct {
next func() (T, bool)
stop func()
toRow func(T) Row
}
func NewBTreeRowIter[T any](t *btree.BTreeG[T], ge, lt T, toRow func(T) Row) RowIter {
next, stop := iter.Pull(func(yield func(T) bool) { t.AscendRange(ge, lt, yield) })
return &btreeIter[T]{next, stop, toRow}
}
func (it *btreeRowIter[T]) Next(ctx *Context) (Row, error) {
v, ok := it.next()
if !ok {
return nil, io.EOF
}
return it.toRow(v), nil
}
func (it *btreeRowIter[T]) Close(*Context) error {
it.stop()
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment