Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This implementation grows indefinitely if you repeatedly push to the head and remove from the tail, even if the max number of elements in the array is small


Does it definitely do that? You could easily avoid it by making the "resize" really a move if you don't actually need more space.

I feel like they're over-selling it anyway by comparing to `std::deque` (which is not hard to beat). The only advantage this has over a standard ring buffer (like Rust's VecDeque) is that the data is completely contiguous, but you'll pay a small performance cost for that (regular memmove's when used as a queue), and I'm not sure how useful it is anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: