JavaScript数据结构之链表
function defaultEquals (a, b) { return a===b } class Node{ constructor(element) { this.element = element this.next=undefined } } class LinkedList { constructor(equalsFn =defaultEquals
function defaultEquals (a, b) { return a===b } class Node{ constructor(element) { this.element = element this.next=undefined } } class LinkedList { constructor(equalsFn =defaultEquals
class Deque { constructor() { this.list = {} this.count = 0 this.lowestrCount = 0 } //在双端队列前端添加 addFront(el){ if(this.isEmpty()){ this.addBack(el) } else if (this.low
class Queue{ constructor() { this.count = 0 this.list = {} this.lowestCount=0 } //往队列添加元素 enqueue (element) { this.list[this.count] = element this.count++ } //检测队列是
class Stack { constructor() { this.item={} this.count=0 } //栈顶添加 push(item){ this.item[this.count]=item this.count++ } //删除 pop(){ if(this.isEmpty()){ retur