All Projects → blakeembrey → deque

blakeembrey / deque

Licence: other
JavaScript implementation of a double-ended queue

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to deque

ctl
My variant of the C Template Library
Stars: ✭ 105 (+517.65%)
Mutual labels:  stack, queue, iterator, deque
Javascript Datastructures Algorithms
📚 collection of JavaScript and TypeScript data structures and algorithms for education purposes. Source code bundle of JavaScript algorithms and data structures book
Stars: ✭ 3,221 (+18847.06%)
Mutual labels:  linked-list, stack, queue, deque
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+847.06%)
Mutual labels:  linked-list, stack, queue
Iruka
A collection of classical data structures ⛩ and algorithms 🏃‍♂️ implemented in Typescript with video lectures 📹.
Stars: ✭ 625 (+3576.47%)
Mutual labels:  linked-list, stack, queue
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (+876.47%)
Mutual labels:  linked-list, stack, queue
Data Structures
Common data structures and algorithms implemented in JavaScript
Stars: ✭ 139 (+717.65%)
Mutual labels:  linked-list, stack, queue
Data Structures
This repository contains some data structures implementation in C programming language. I wrote the tutorial posts about these data structures on my personal blog site in Bengali language. If you know Bengali then visit my site
Stars: ✭ 82 (+382.35%)
Mutual labels:  linked-list, stack, queue
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (+1000%)
Mutual labels:  linked-list, stack, queue
Cdsa
A library of generic intrusive data structures and algorithms in ANSI C
Stars: ✭ 549 (+3129.41%)
Mutual labels:  linked-list, stack, queue
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (+211.76%)
Mutual labels:  linked-list, stack, queue
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+2629.41%)
Mutual labels:  linked-list, stack, queue
Libft
42 library of basic C functions - queues, lists, memory operations and more 😄
Stars: ✭ 21 (+23.53%)
Mutual labels:  linked-list, queue, double-linked-list
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (+611.76%)
Mutual labels:  linked-list, stack, queue
Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (+876.47%)
Mutual labels:  linked-list, stack, queue
Learningmasteringalgorithms C
Mastering Algorithms with C 《算法精解:C语言描述》源码及Xcode工程、Linux工程
Stars: ✭ 615 (+3517.65%)
Mutual labels:  linked-list, stack, queue
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+6535.29%)
Mutual labels:  linked-list, stack, queue
quetie
🎀 Just the cutest and tiniest queue/deque implementation!
Stars: ✭ 111 (+552.94%)
Mutual labels:  stack, queue, deque
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+26023.53%)
Mutual labels:  linked-list, stack, queue
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (+105.88%)
Mutual labels:  linked-list, stack, queue
needle
📌📚 An extensive standalone data structure library for JavaScript.
Stars: ✭ 25 (+47.06%)
Mutual labels:  linked-list, stack, queue

Deque

NPM version NPM downloads Build status Test coverage

Deques are a generalization of stacks and queues (the name is pronounced "deck" and is short for "double-ended queue"). -- Python collections.

Installation

npm install @blakeembrey/deque --save

Usage

  • size Returns the number of elements in the deque.
  • push(x) Add x to right side of the deque.
  • pushLeft(x) Add x to the left side of the deque.
  • clear() Remove all elements from the deque leaving it with length 0.
  • extend(iterable) Extend the right side of the deque by appending elements from iterable.
  • extendLeft(iterable) Extend the left side of the deque by appending elements from iterable.
  • peek(i) Return the element at index i in the deque.
  • indexOf(x, start?) Return the position of x in the deque.
  • has(x) Return a boolean indicating whether x is in the deque.
  • insert(i, x) Insert x into the deque at position i.
  • pop() Remove and return an element from the right side of the deque. If no elements are present, throws RangeError.
  • popLeft() Return and return an element from the left side of the deque. If no elements are present, throws RangeError.
  • delete(i) Delete the value at position i.
  • reverse() Reverse the elements of the deque in-place.
  • rotate(n=1) Rotate the deque n steps to the right.
  • entries() Return an iterable of deque.
  • @@iterator() Return an iterable of deque.
import { Deque } from '@blakeembrey/deque'

const d = new Deque('ghi')

for (const value of d) {
  console.log(value.toUpperCase()) //=> G H I
}

d.push('j')
d.pushLeft('f')
d //=> Deque(['f', 'g', 'h', 'i', 'j'])

d.pop() //=> 'j'
d.popLeft() //=> 'f'

Array.from(d) //=> ['g', 'h', 'i']

d.peek(0) //=> 'g'
d.peek(-1) //=> 'i'

d.extend('jkl')
d //=> Deque(['g', 'h', 'i', 'j', 'k', 'l'])

d.rotate(1)
d //=> Deque(['l', 'g', 'h', 'i', 'j', 'k'])

d.rotate(-1)
d //=> Deque(['g', 'h', 'i', 'j', 'k', 'l'])

const d2 = new Deque(d)

d2 //=> Deque(['g', 'h', 'i', 'j', 'k', 'l'])

TypeScript

This project uses TypeScript and publishes definitions on NPM.

Reference

Circular array implementation originally based on denque with additional optimizations.

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].