Skip to main content

Crate linear_deque

Crate linear_deque 

Source
Expand description

A double-ended queue that can be sliced at any time without preparation.

§LinearDeque vs VecDeque

§Slicing

The standard VecDeque uses a ring buffer. It requires that the make_contiguous method is called to ensure that the deque content can all be referenced in a single slice. make_contiguous is only callable on a mutable instance of the deque.

The LinearDeque provided by this lib uses a linear buffer, keeping all its content contiguous and allowing to have a slice with all the content at any time, even when the deque is not mutable.

§Memory Usage

By using a ring buffer, all spare memory allocated by the standard VecDeque can be used for elements added at both the front and the back ends.

Using a linear buffer, each end of the LinearDeque have its own reserved memory, so it tends to use more memory a do more re-allocations than VecDeque.

§no_std, alloc and the std feature

For backward compatibility, this crate uses std by default. The std feature can be disabled to use this crate in a no_std environment. In that case, the crate will use the alloc crate instead of std for heap allocation and other utilities.

The only functionality that is gated behind the std feature is the implementation of Read and Write traits for LinearDeque<u8>.

To disable the std feature, add the following to the dependencies in your Cargo.toml:

linear-deque = { version = "0.1", default-features = false }

Structs§

Drain
A draining iterator over the elements of a LinearDeque.
IntoIter
An owning iterator over the elements of a LinearDeque.
LinearDeque
A double-ended queue implemented with a growable linear buffer.

Enums§

SetReservedSpace
Defines what happens to the reserved space of one of the deque ends on a call to set_reserved_space.