Giter VIP home page Giter VIP logo

Comments (4)

myrrlyn avatar myrrlyn commented on June 15, 2024

It is immediately available with this hack: pop_front is .rotate_left(1).pop(), and push_front is .push().rotate_right(1). I have not yet looked at VecDeque in any depth, and so have not made any plans for its API to be ported.

Implementation details of BitSlice pointers allow any object using them to move their starting position up and down inside an element without any cost. BitVec does not currently expose an API to push or pop at the front, though there is no underlying restriction on doing so as long as you are willing to accept that when these events depart the base allocation address, the vector must move its buffer contents within the allocation.

I do not plan to make a channel equivalent at this time, so BitVec alone cannot be split across threads for concurrent add/remove operations.

I can add push/pop front methods in a future release. In the meantime, let me know if the behavior of the described workaround is sufficient.

from bitvec.

ckaran avatar ckaran commented on June 15, 2024

The workaround is fine for now, thank you!

from bitvec.

myrrlyn avatar myrrlyn commented on June 15, 2024

The implementation I assumed I had in play when I wrote this reply is a behavior that I scrapped in favor of a simpler, safer, but more naïve version. BitVec can play much more fast-and-loose with its buffer than BitSlice can, so I'll write an actually-intelligent version of push_front and pop_front in the near future.

.rotate_left(1) moves every bit in the slice; this is not necessary in most cases. If it's a reasonably small vec, it'll still be pretty quick, but I can do better.

from bitvec.

ckaran avatar ckaran commented on June 15, 2024

Thank you for being willing to add this; I'm sure I'm not the only person needing this functionality!

from bitvec.

Related Issues (20)

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.