# fixed-slice-deque
[](./LICENSE)
[](https://github.com/danielsanchezq/fixed-slice-deque/actions?query=workflow%3ACI)
[](https://docs.rs/fixed-slice-deque)
[](https://crates.io/crates/fixed-slice-deque)
### Add the library dependency
```toml
[dependencies]
fixed-slice-deque = "0.5"
```
## Explanation:
A fixed size double-ended queue that `Deref`s into a slice.
For keeping the fixed queue size items pushed out of bounds are pop and returned in inserting
operations.
### Example:
Initialize state, empty, with fixed size of `3`
```txt
`X = None`
+---+---+---+
```
Pushing `1` to the back, since it is empty, `1` is the only item in the deque
```txt
=> push_back(1)
+---+---+---+
```
Push `2` to the front (left)
```txt
=> push_front(2)
+---+---+---+
```
Push again to the back, a single `3`. The deque now **is full**
```txt
=> push_back(3)
+---+---+---+
```
We try to add a new item at the back, but we would have one extra, the first item (`2`) is pop
to the left and returned. We keep the elements and the fixed size
```txt
=> push_back(4)
+---+---+---+
```
The same happens when pushing to the front again, the back-most (right) item is pop and returned
```txt
=> push_front(5)
+---+---+---+
```
It is implemented as a wrapper over `SliceDeque` [**`slice-deque`** crate](<https://crates.io/crates/slice-deque>)
Almost every orignal `SliceDeque` method is wrapped.
Please refer to it's twin method [documentation](https://docs.rs/slice-deque/latest/slice_deque/)
for internal functionality.
## License
This project is licensed under either of
* Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in SliceDeque by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.