Does Zig std have a double-ended queue?

Does Zig std have a double-ended queue? Something like VecDeque in Rust?

You can check the std lib docs

https://ziglang.org/documentation/master/std/

There are actually 4 implementations in the std library
std.RingBuffer, unfortunately isnt generic
std.fifo.LinearFifo is a generic and growable ring buffer
std.compress.flate.CurcularBuffer specific to flate compression
std.compress.lzma.decode.lzbuffer.LzCircularBuffer specific to lzma compression

std.fifo.LinearFifo is a direct equivalent to VecDeque from rust

If that is so, that’s questionable naming? Also, how is the LinearFifo Deque ? Where’s the methods to put and get from the ā€˜other’ end?

ah my apologies. I was focused on the ring buffer aspect of VecDeque I overlooked the double ended features.
A double ended queue is basically an extension of a ring buffer, you can copy LinearFifo and modify it to have a double ended API, you can’t call it a fifo after you do that ofc.

ā€œFifiā€ sounds like a dog’s name… :smiley:

1 Like