数据结构_队列
//队列,先进先出 class Queue { constructor () { this.items = [] } //入队 enqueue (elem) { return this.items.push(this.items) } //出队 dequeue () { return this.items.shift() } //查看队首元素 front () { return this.items[0] } //是否为空 isEmpty () { return this.items.length <= 0 } //清空队列 clear () { this.items = [] return true } //队列长度 size () { return this.items.length } }

浙公网安备 33010602011771号