public async ValueTask <bool> MoveNextAsync() { for (; ;) { if (_once) { if (_queue.Dequeue(out _current)) { return(true); } return(false); } while (await _source.MoveNextAsync()) { if (_size != 0) { _size--; } else { _queue.Dequeue(out _); } _queue.Enqueue(_source.Current); } _once = true; } }
public async ValueTask <bool> MoveNextAsync() { while (_size != 0) { if (await _source.MoveNextAsync()) { _queue.Enqueue(_source.Current); _size--; } else { _size = 0; return(false); } } if (await _source.MoveNextAsync()) { _queue.Dequeue(out _current); _queue.Enqueue(_source.Current); return(true); } return(false); }
public async ValueTask <bool> MoveNextAsync() { for (; ;) { if (_done) { if (_buffers.Dequeue(out _buffer)) { return(true); } return(false); } if (await _source.MoveNextAsync()) { if (_index == 0) { _buffers.Enqueue(_bufferSupplier()); } _index++; _count++; _buffers.ForEach(_source.Current, (b, v) => b.Add(v)); } else { _done = true; continue; } if (_index == _skip) { _index = 0; } if (_count == _size) { _count -= _skip; _buffers.Dequeue(out _buffer); return(true); } } }