A fast ring-buffer deque (double-ended queue) implementation in Go with O(1) operations and optimized memory performance.
Deque is a Go library that provides a high-performance double-ended queue (deque) data structure using a ring buffer. It efficiently supports both queue (FIFO) and stack (LIFO) operations with constant-time performance, optimized for CPU and garbage collection efficiency.
Go developers who need a memory-efficient and fast deque implementation for scenarios like task scheduling, buffering, or algorithm implementations requiring O(1) operations at both ends.
Developers choose this over alternatives because it uses a ring buffer that reduces allocations and GC pauses compared to slice or linked-list implementations, offers type safety via Go generics, and provides iterators for efficient traversal and removal.
Fast ring-buffer deque (double-ended queue)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses a circular buffer that resizes by powers of two, reducing allocations and GC pauses compared to slice or linked-list implementations, as highlighted in the README for optimal performance.
Provides O(1) addition and removal at both ends, enabling high-throughput queue and stack operations suitable for real-time systems or algorithm implementations.
Leverages Go generics for compile-time type checks, allowing deques of any specified type and ensuring type-safe usage without runtime assertions.
Includes iterators for traversal and item removal, compatible with Go's stdlib slices and iter packages, facilitating efficient data processing and avoiding intermediate resizes.
Panics when reading from an empty deque, forcing explicit length checks and adding boilerplate, which can lead to runtime crashes if not carefully handled in production code.
Leaves concurrency safety entirely to the application, requiring external synchronization like mutexes, complicating code in multi-goroutine environments and increasing development overhead.
Requires tuning of base capacity via SetBaseCap to minimize resizing; improper settings can lead to frequent reallocations, negating performance benefits in unbalanced workloads.