tcbrindle / flux

A C++20 library for sequence-orientated programming
https://tristanbrindle.com/flux/
Boost Software License 1.0
479 stars 29 forks source link

Add slide adaptor #39

Closed tcbrindle closed 1 year ago

tcbrindle commented 1 year ago

This takes a runtime window size n, and yields sliding windows of size n over the source sequence. For example, given a source sequence [1, 2, 3, 4, 5] and a window size of 2, will return

[[1, 2], [2, 3], [3, 4], [4, 5]]

It is multipass only, since we need to use two cursors to keep track of the start and end of the window.

codecov[bot] commented 1 year ago

Codecov Report

Base: 98.24% // Head: 98.27% // Increases project coverage by +0.03% :tada:

Coverage data is based on head (339b167) compared to base (1c7b032). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #39 +/- ## ========================================== + Coverage 98.24% 98.27% +0.03% ========================================== Files 61 62 +1 Lines 2160 2205 +45 ========================================== + Hits 2122 2167 +45 Misses 38 38 ``` | [Impacted Files](https://codecov.io/gh/tcbrindle/flux/pull/39?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle) | Coverage Δ | | |---|---|---| | [include/flux/core/inline\_sequence\_base.hpp](https://codecov.io/gh/tcbrindle/flux/pull/39?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle#diff-aW5jbHVkZS9mbHV4L2NvcmUvaW5saW5lX3NlcXVlbmNlX2Jhc2UuaHBw) | `92.30% <ø> (ø)` | | | [include/flux/op/slide.hpp](https://codecov.io/gh/tcbrindle/flux/pull/39?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle#diff-aW5jbHVkZS9mbHV4L29wL3NsaWRlLmhwcA==) | `100.00% <100.00%> (ø)` | | | [include/flux/op/count.hpp](https://codecov.io/gh/tcbrindle/flux/pull/39?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle#diff-aW5jbHVkZS9mbHV4L29wL2NvdW50LmhwcA==) | `100.00% <0.00%> (ø)` | | | [include/flux/op/slice.hpp](https://codecov.io/gh/tcbrindle/flux/pull/39?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle#diff-aW5jbHVkZS9mbHV4L29wL3NsaWNlLmhwcA==) | `100.00% <0.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.