Comments (4)
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.
The workaround is fine for now, thank you!
from bitvec.
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.
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)
- Compilation errors due to missing atomics even though `atomic` feature is not enabled HOT 3
- Ordering bug comparing Vec & Slice
- [Question] Is is possible to use BitArray with const generics? HOT 1
- `bitarr![const ...]` throws mismatched types HOT 1
- Bug (?): load() loads wrong value
- Can I implement `TrustedLen` for wrapper of `Iter` and `BitValIter`?
- Can ends_with be optimized further?
- Use #[track_caller] attribute HOT 2
- Dead documentation link HOT 4
- `to_bitvec` and related functions returning invalid values HOT 3
- `bitvec` contains unsound global state HOT 4
- `chunks_exact_mut()` occasionally doesn't return the last chunk when `step_by()` is involved
- Difference between `BitVec` and `BitVec<T, O>`? HOT 1
- `copy_within` panics on empty range
- `bitarr!` macro link incorrect
- Implement `BitStore` for signed integer types
- impl `TryFrom<BitVec>` for `BitArray`
- How to convert bitvec to slice? HOT 1
- Build for STM32 (no_std, thumbv7m-none-eabi) - no global memory allocator
- Regarding the safety of `chunks_mut(...).remove_alias()` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bitvec.