Created
September 18, 2025 18:41
-
-
Save icholy/f2d83673f3477780661c66e21cb426f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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