https://github.com/wangdahoo/deque
double-ended queue.
https://github.com/wangdahoo/deque
Last synced: 23 days ago
JSON representation
double-ended queue.
- Host: GitHub
- URL: https://github.com/wangdahoo/deque
- Owner: wangdahoo
- Created: 2017-10-10T03:14:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-24T03:01:08.000Z (about 7 years ago)
- Last Synced: 2025-02-27T05:16:10.522Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Double-ended Queue
> 简单的双向队列实现
### Install
```bash
$ yarn add simple-deque
```
### How to Use
```js
const Deque = require('simple-deque')
const deque = new Deque([3.14, 'hello, deque.', false])
const it = deque.iterator()
let next = it.next()
while (!next.done) {
next = it.next()
console.log(next.value)
}
```
### API
- `unshift(obj)` - insert from the head
- `shift()` - delete from the head
- `push(obj)` - insert from the tail
- `pop()` - delete from the tail
- `values()` - return all data values in array
- `nodes()` - return all nodes in array