https://github.com/jfontan/go-jdeque
Chunk based deque for Go
https://github.com/jfontan/go-jdeque
deque go queue
Last synced: about 1 month ago
JSON representation
Chunk based deque for Go
- Host: GitHub
- URL: https://github.com/jfontan/go-jdeque
- Owner: jfontan
- License: mit
- Created: 2022-01-25T21:19:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-23T21:33:26.000Z (about 3 years ago)
- Last Synced: 2024-06-19T13:47:01.655Z (12 months ago)
- Topics: deque, go, queue
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-jdeque
This queue is implemented with a linked list of chunks. It is a deque and values can be pushed and popped front or back.
Uses generics and needs go >= 1.8.
Example:
```go
q := jdeque.New[int](10)q.PushFront(0)
q.PushBack(1)v, ok := q.PopFront() // 0, true
v, ok = q.PopFront() // 1, true
v, ok = q.PopFront() // 0, false
```## Benchmarks
This is comparing different chunk sizes and the following libraries:
* https://github.com/carlmjohnson/deque
* https://github.com/sekoyo/deque```
BenchmarkJqueue256
BenchmarkJqueue256-16 7 164305208 ns/op 17978925 B/op 16746 allocs/op
BenchmarkJqueue1024
BenchmarkJqueue1024-16 7 153615136 ns/op 17352717 B/op 4189 allocs/op
BenchmarkJqueue1048576
BenchmarkJqueue1048576-16 7 148296433 ns/op 17976419 B/op 6 allocs/op
BenchmarkCarlmjohnson
BenchmarkCarlmjohnson-16 7 155473335 ns/op 87885730 B/op 7 allocs/op
BenchmarkSekoyo
BenchmarkSekoyo-16 5 208200644 ns/op 214748377 B/op 5 allocs/op
```