Skip to content

A "sliding window" iterator.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rozbb/rust-iterslide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-iterslide

Version Docs Build Status

This package implements "sliding window" functionality for any iterator over a Cloneable item.

Example

use iterslide::SlideIterator;

fn main() {
    let v: Vec<i8> = vec![1, 2, 3, 4, 5];

    for window in v.slide(3) {
        // window is a VecDeque<i8>
        println!("{:?}", window);
    }
}

Output:

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

Alternatives

  • Rust's windows method for slices does what you would expect. This does no allocation. However, this is only implemented for slices.

  • itertools' tuple_windows method returns a sliding window iterator over tuples instead of VecDeques. This saves a VecDeque allocation in construction of the iterator. However, tuple_windows is limited to window sizes of at most 4.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

About

A "sliding window" iterator.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages