FastPriorityQueue.js:JavaScript中基于堆的快速优先级队列
在优先队列中,您可以...
快速查询或删除(轮询)最小的元素
快速插入元素
实际上,“快速”通常是指对数时间(O(log n))。
堆可用于实现优先级队列。
FastPriorityQueue尝试在JavaScript中实现面向性能的优先级队列。 它可能比其他类似的库快几倍。 当性能很重要时,它是理想的选择。
许可证:Apache License 2.0
用法
var x = new FastPriorityQueue ( ) ;
x . add ( 1 ) ;
x . add ( 0 ) ;
x . add ( 5 ) ;
x . add ( 4 ) ;
x . add ( 3 ) ;
x . peek ( ) ; // should return 0, leaves x unchanged
评论0
最新资源