Skip to content

feat: add Sliding window function#47

Merged
rjNemo merged 1 commit intomainfrom
feat/issue-19-sliding-window
Nov 16, 2025
Merged

feat: add Sliding window function#47
rjNemo merged 1 commit intomainfrom
feat/issue-19-sliding-window

Conversation

@rjNemo
Copy link
Owner

@rjNemo rjNemo commented Nov 14, 2025

Summary

  • Add Sliding: creates sliding window views of a slice with specified window size

Implementation

  • sliding.go: Sliding implementation with pre-allocation
  • Returns independent window copies (non-mutating)
  • Handles edge cases: empty, size <= 0, size > length, size == length
  • Comprehensive tests
  • Benchmark included

Testing

go test -v -run TestSliding
go test -bench=BenchmarkSliding -benchmem

All tests pass.

Examples

Sliding([]int{1,2,3,4,5}, 3)      // [[1,2,3], [2,3,4], [3,4,5]]
Sliding([]int{1,2,3,4}, 2)        // [[1,2], [2,3], [3,4]]
Sliding([]int{1,2,3}, 1)          // [[1], [2], [3]]
Sliding([]int{1,2,3}, 3)          // [[1,2,3]]
Sliding([]int{1,2,3}, 5)          // []

Use Cases

  • Moving averages in time series data
  • N-gram generation in text processing
  • Pattern matching across sequences
  • Rolling window computations

Related

Resolves Issue 19 from ACTION_PLAN.md

🤖 Generated with Claude Code

- Add Sliding: creates sliding window views of a slice
- Pre-allocated for optimal performance
- Returns independent window copies (non-mutating)
- Comprehensive tests including edge cases
- Benchmark included

Example: Sliding([1,2,3,4,5], 3) → [[1,2,3], [2,3,4], [3,4,5]]

Resolves Issue 19

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (d622c8c) to head (e03ba5d).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #47      +/-   ##
==========================================
+ Coverage   98.63%   98.67%   +0.03%     
==========================================
  Files          39       40       +1     
  Lines         367      377      +10     
==========================================
+ Hits          362      372      +10     
  Misses          4        4              
  Partials        1        1              
Flag Coverage Δ
unittests 98.67% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rjNemo rjNemo merged commit 85f73f6 into main Nov 16, 2025
4 checks passed
@rjNemo rjNemo deleted the feat/issue-19-sliding-window branch November 16, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant