Skip to content
A highly optimized double-ended queue
Branch: master
Clone or download
Latest commit 4e71c3b Feb 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore add the deque, including test cases Feb 1, 2019
.travis.yml add .travis.yml Feb 1, 2019
LICENSE Initial commit Feb 1, 2019
README.md update the example Feb 2, 2019
benchmark_test.go rename benchmarks Feb 2, 2019
chunkPool.go chunkPool is now a standalone struct Feb 11, 2019
deque.go add DequeueMany Feb 12, 2019
deque_test.go add more test cases Feb 12, 2019
example_test.go update the example Feb 2, 2019
go.mod
interface.go update documentation Feb 13, 2019

README.md

Overview

Deque is a highly optimized double-ended queue.

Build Status

Benchmark

Benchmark_PushBack/Deque            20000000            81.3 ns/op        24 B/op          1 allocs/op
Benchmark_PushBack/list.List         5000000           281 ns/op          56 B/op          2 allocs/op
Benchmark_PushFront/Deque           30000000            70.6 ns/op        24 B/op          1 allocs/op
Benchmark_PushFront/list.List        5000000           276 ns/op          56 B/op          2 allocs/op
Benchmark_Random/Deque              50000000            32.1 ns/op         4 B/op          0 allocs/op
Benchmark_Random/list.List          30000000           123 ns/op          28 B/op          1 allocs/op

Usage

import "github.com/edwingeng/deque"

dq := NewDeque()
dq.PushBack(100)
dq.PushBack(200)
dq.PushBack(300)
for !dq.Empty() {
	fmt.Println(dq.PopFront())
}

dq.PushFront(100)
dq.PushFront(200)
dq.PushFront(300)
for i, n := 0, dq.Len(); i < n; i++ {
	fmt.Println(dq.PopFront())
}

// Output:
// 100
// 200
// 300
// 300
// 200
// 100

Documentation

https://godoc.org/github.com/edwingeng/deque

You can’t perform that action at this time.