range_vec 0.2.0

Fast indexed access to a range of mostly-default values
Documentation
  • Coverage
  • 100%
    18 out of 18 items documented13 out of 16 items with examples
  • Size
  • Source code size: 40.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.16 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • dacid44/range_vec
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • dacid44

range_vec

RangeVec is a data structure for Rust that may have a value for any index, but where only a small range of values are non-default, and only these are stored. It is based on a ring buffer (VecDeque) so that it may efficiently grow in either direction. It is useful for applications such as backing storage for scrolling data, and was originally designed for use in change tracking for an emulator's memory viewer.

RangeVec requires that the stored type implement Default and Eq, and it will return the default value whenever an index outside of its stored range is accessed. The stored range will automatically be grown or shrunk to exactly match the smallest possible range of non-default values after every mutation. To facilitate this, all mutable access is currently done through closures, so that the ring buffer may be adjusted based on whether the value is equal to the default after mutation. There may be a guard-based API in the future as well.

License

This library is licensed under either the Apache License, version 2.0, or the MIT License.