#queue #limited #circular #complexity #full #overrides #default

limited-queue

a limited queue that overrides the oldest data if trying to push a data when the queue is full

1 unstable release

0.1.5 Jul 12, 2024
0.1.4 Jul 12, 2024

#890 in Algorithms

Download history 2/week @ 2024-10-06 11/week @ 2024-10-13 1/week @ 2024-10-20 1/week @ 2024-10-27 6/week @ 2024-11-03 1/week @ 2024-11-10 2/week @ 2024-11-24 1/week @ 2024-12-01 21/week @ 2024-12-08 7/week @ 2024-12-15

161 downloads per month
Used in super-rodio

MIT license

15KB
222 lines

Limited Queue

Crates.io Version GitHub top language GitHub CI Status Crates.io Downloads License

A circular queue that overrides the oldest data if trying to push a data when the queue is full.

All operations are of O(1) complexity, except the constructor with O(Vec::with_capacity).

The optional method pop is provided when T satisfies trait bound Default.

Comparison

There is a similar library circular-queue I found, but without the basic peek and pop operations. The comparison for now is listed below:

LimitedQueue circular-queue
Algorithm circular queue (front-rear, without additional element slot) circular queue (based on len and capacity provided by Vec)
Element trait bound needed No, optionally Default for pop method -
push, size-related methods
peek, pop support ✅: peek
✅: pop for T: Default
Indexing
- [0, len)
- support [idx]
- support get(idx)
- optionally mutable ([idx])
Iterator
- front to rear

- both ways
- optionally mutable
clear complexity O(1) O(Vec::clear)
serde support ❌ (TODO)

We welcome any kinds of contributions, please don't be hesitate to submit issues & PRs.

Setup

Please run scripts/setup.sh to setup for committing. Currently, the script registers a git pre-commit hook.

No runtime deps

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy