0%

js data stuct

stack

dequeue

priority-queue

优先队列

1
2
3
4
5
6
7
8
9
10
11
12
13
let isAdded = false
for(let i=0;i<queue.length;i++){
if(element.priority< queue[i].priority){
items.splice(i,0,element)
isAdded = true
break
}
}

if(!isAdded){
items.push(element)
}

circular-queue

循环队列

1
queue.enqueue(queue.dequeue)