JavaScript数据结构之链表

function defaultEquals (a, b) { return a===b } class Node{ constructor(element) { this.element = element this.next=undefined } } class LinkedList { constructor(equalsFn =defaultEquals

- 阅读全文 -

JavaScript数据结构之双端队列

class Deque { constructor() { this.list = {} this.count = 0 this.lowestrCount = 0 } //在双端队列前端添加 addFront(el){ if(this.isEmpty()){ this.addBack(el) } else if (this.low

- 阅读全文 -

JavaScript数据结构之队列

class Queue{ constructor() { this.count = 0 this.list = {} this.lowestCount=0 } //往队列添加元素 enqueue (element) { this.list[this.count] = element this.count++ } //检测队列是

- 阅读全文 -

JavaScript不用数组实现栈的方式

class Stack { constructor() { this.item={} this.count=0 } //栈顶添加 push(item){ this.item[this.count]=item this.count++ } //删除 pop(){ if(this.isEmpty()){ retur

- 阅读全文 -