pinned-deque

Crates.iopinned-deque
lib.rspinned-deque
version0.2.0
sourcesrc
created_at2024-09-09 16:20:41.971434
updated_at2024-10-19 14:59:49.936448
descriptionA high-performance double-ended queue, inspired by BOOST deque. Every element in this deque is pinned until its popping.
homepage
repositoryhttps://github.com/TimeExceed/pinned-deque
max_upload_size
id1369471
size110,067
Taoda (TimeExceed)

documentation

README

Pinned Deque

This is a high-performance double-ended queue, inspired by BOOST deque. Once an element is pushed into this queue, it will never move until it is popped. So, pointers to elements in this queue will never be invalidated when other elements are pushed or popped.

Complexity

Operation Complexity
push_front/push_back O(1)
pop_front/pop_back O(1)
front/front_mut O(1)
back/back_mut O(1)
get/get_mut O(1)
iter/iter_mut O(1)
next in Iter/IterMut O(1)
next_back in Iter/IterMut O(1)

Benchmarks

NOTICE: It is important to run benchmarks in your environement, especially under your allocator. Our results are collected under jemalloc.

  • In most cases, this deque is among the best choices.

push_back & push_front

  • For small datasets, this deque is almost as fast as Vec and VecDeque.
  • For large datasets, this deque intends to be faster. This is because it is hard for allocators to find large, consecutive memory regions. And this deque never requests such allocations.
  • As conclusions, this deque is more predictable than Vec and VecDeque.

Push back

Push front

iteration

  • Iterations over this deque is almost as fast as those over Vec and VecDeque.

Iter

Iter backwards

indexing

  • Although indexing on this deque (get/get_mut) takes constant time, it is not as fast as Vec and VecDeque. It is about 10x slower.

Get Middle

Commit count: 10

cargo fmt