---
title: SlidingWindows
framework: createmlcomponents
role: symbol
role_heading: Structure
path: createmlcomponents/slidingwindows
---

# SlidingWindows

A sequence of windows on a time series shaped array.

## Declaration

```swift
struct SlidingWindows<Scalar> where Scalar : MLShapedArrayScalar
```

## Overview

Overview The shape of each window in the sequence is [length, featureSize]. The sequence will return as many windows as fit in the input. For example, an input shaped array of shape [8, 1] using stride of 1 and length of 4 will produce 5 examples: [[1], [2], [3], [4]] [[2], [3], [4], [5]] [[3], [4], [5], [6]] [[4], [5], [6], [7]] [[5], [6], [7], [8]]

## Topics

### Creating a sliding window

- [init(input:length:stride:)](createmlcomponents/slidingwindows/init(input:length:stride:).md)

### Inspecting the sliding window

- [endIndex](createmlcomponents/slidingwindows/endindex.md)
- [input](createmlcomponents/slidingwindows/input.md)
- [length](createmlcomponents/slidingwindows/length.md)
- [startIndex](createmlcomponents/slidingwindows/startindex.md)
- [stride](createmlcomponents/slidingwindows/stride.md)

### Getting the index

- [index(_:offsetBy:)](createmlcomponents/slidingwindows/index(_:offsetby:).md)
- [index(after:)](createmlcomponents/slidingwindows/index(after:).md)
- [index(before:)](createmlcomponents/slidingwindows/index(before:).md)

### Getting the subscript

- [subscript(_:)](createmlcomponents/slidingwindows/subscript(_:).md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### Time-based components

- [Creating a time-series classifier](createmlcomponents/creating-a-time-series-classifier.md)
- [Creating a time-series forecaster](createmlcomponents/creating-a-time-series-forecaster.md)
- [DateFeatures](createmlcomponents/datefeatures.md)
- [DateFeatureExtractor](createmlcomponents/datefeatureextractor.md)
- [LinearTimeSeriesForecaster](createmlcomponents/lineartimeseriesforecaster.md)
- [LinearTimeSeriesForecasterConfiguration](createmlcomponents/lineartimeseriesforecasterconfiguration.md)
- [TimeSeriesForecasterBatches](createmlcomponents/timeseriesforecasterbatches.md)
- [TimeSeriesForecasterAnnotatedWindows](createmlcomponents/timeseriesforecasterannotatedwindows.md)
- [TemporalFeature](createmlcomponents/temporalfeature.md)
- [TemporalSequence](createmlcomponents/temporalsequence.md)
- [TemporalSegmentIdentifier](createmlcomponents/temporalsegmentidentifier.md)
- [SlidingWindowTransformer](createmlcomponents/slidingwindowtransformer.md)
- [Downsampler](createmlcomponents/downsampler.md)
- [VideoReader](createmlcomponents/videoreader.md)
- [TemporalFileSegment](createmlcomponents/temporalfilesegment.md)
