Coder Social home page Coder Social logo

arrav's Introduction

Crates.io Documentation Build Status Codecov

A sentinel-based, heapless, Vec-like type.

Arrays are great, because they do not require allocation. But arrays are fixed-size.

Slices are great, because you can make them smaller. But slices aren't Sized.

Vectors are great, because you can make them bigger. But vectors require allocation.

This type provides a type that acts like a vector but is represented exactly like an array. Unlike other array-backed vector-like types, but like C-style strings and arrays, Arrav uses a sentinel value to indicate unoccupied elements. This makes push and pop a little slower, but avoids having to store the length separately. The trade-off is that the sentinel value can no longer be stored in the array.

Arrav is intended for when you have a small but variable number of small values that you want to store compactly (e.g., because they're going to be stored in a large number of elements). This is also why the "search" for the sentinel value to determine the array's length (and thus for push and pop) is unlikely to matter in practice.

Unlike C-style strings and arrays, which use NULL as the sentinel, Arrav uses the max value of the type (like std::u8::MAX). This means that unless you are saturating the type's range, you won't even notice the sentinel.

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, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

arrav's People

Contributors

jonhoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

crazyfork

arrav's Issues

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.