Giter Site home page Giter Site logo

flo-l / rust-sliding_windows Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 1.0 677 KB

This repository contains a non-copying implementation of a sliding windows iterator adaptor.

Home Page: https://flo-l.github.io/rust-sliding_windows/

License: MIT License

Rust 99.20% HTML 0.80%
crates iterator rust

rust-sliding_windows's People

Contributors

flo-l avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vringar

rust-sliding_windows's Issues

Performance improvements

Instead of using VecDeque as storage it's also possible to improve performance immensely by just using a bigger Vec and shifting all elements just when it's end is reached. Eg. a Vec with size = window_size * 2 would be a lot more CPU efficient but would just use a bit more memory.

Implement Storage with VecDeque or similar

Storage is currently implemented using a Vec as a backing storage. This becomes inefficient for huge window sizes, as the whole array needs to be shifted on every call to next() sometimes.

As noted in #1 it's very hard to implement Storage generically over any container.

  • One would lose the ability of Window to deref to a (mut) slice.
  • Window probably has to implement Iterator or Index/IndexMut.

I'd be happy to merge a PR that implements Storage generically over containers if good solutions to the above problems are found and if no functionality gets lost.

Anyway I'd also merge a PR implementing another adaptor, which uses a VecDeque or anything efficient for huge window sizes.

Needs polishing

Before announcing this on reddit etc. this repo needs some polishing.

Wishlist

  • better readme
  • shorter/better type names (SlidingWindowStorage is horrible)
  • more storage types (VecDeque), maybe a trait so users can implement their own won't be done
  • macro to make usage even easier Is this really needed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.