| 539 | explicit FlattenIterator(Iterator<Iterator<T>> it) : parent_(std::move(it)) {} |
| 540 | |
| 541 | Result<T> Next() { |
| 542 | if (IsIterationEnd(child_)) { |
| 543 | // Pop from parent's iterator. |
| 544 | ARROW_ASSIGN_OR_RAISE(child_, parent_.Next()); |
| 545 | |
| 546 | // Check if final iteration reached. |
| 547 | if (IsIterationEnd(child_)) { |
| 548 | return IterationTraits<T>::End(); |
| 549 | } |
| 550 | |
| 551 | return Next(); |
| 552 | } |
| 553 | |
| 554 | // Pop from child_ and check for depletion. |
| 555 | ARROW_ASSIGN_OR_RAISE(T out, child_.Next()); |
| 556 | if (IsIterationEnd(out)) { |
| 557 | // Reset state such that we pop from parent on the recursive call |
| 558 | child_ = IterationTraits<Iterator<T>>::End(); |
| 559 | |
| 560 | return Next(); |
| 561 | } |
| 562 | |
| 563 | return out; |
| 564 | } |
| 565 | |
| 566 | private: |
| 567 | Iterator<Iterator<T>> parent_; |
nothing calls this directly
no test coverage detected