首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

PriorityQueue (class)

介绍

(没有可用的版本信息,可能只在Git中)

PriorityQueue与队列非常相似。值以指定的优先级推入队列,优先级最高的值始终位于队列的前端。

使用最大堆实现。

注意:对于具有相同优先级的值,“先进先出”排序被保留。 注意:迭代PriorityQueue是破坏性的,相当于连续的弹出操作,直到队列为空。

类简介

Ds\PriorityQueue implements Ds\Collection {

/ *常量* /

const int MIN_CAPACITY = 8 ;

/* 方法 */

代码语言:javascript
复制
public void allocate ( int $capacity )
代码语言:javascript
复制
public int capacity ( void )
代码语言:javascript
复制
public void clear ( void )
代码语言:javascript
复制
public Ds\PriorityQueue copy ( void )
代码语言:javascript
复制
public bool isEmpty ( void )
代码语言:javascript
复制
public mixed peek ( void )
代码语言:javascript
复制
public mixed pop ( void )
代码语言:javascript
复制
public void push ( mixed $value , int $priority )
代码语言:javascript
复制
public array toArray ( void )

}

预定义的常量

Ds\PriorityQueue::MIN_CAPACITY

目录

  • Ds \ PriorityQueue :: allocate - 为所需容量分配足够的内存。
  • Ds \ PriorityQueue :: capacity - 返回当前容量。
  • Ds \ PriorityQueue :: clear - 删除所有值。
  • Ds \ PriorityQueue :: __ construct - 创建一个新实例。
  • Ds \ PriorityQueue :: copy - 返回队列的浅表副本。
  • Ds \ PriorityQueue :: count - 返回队列中值的数量。
  • Ds \ PriorityQueue :: isEmpty - 返回队列是否为空
  • Ds \ PriorityQueue :: jsonSerialize - 返回可以转换为JSON的表示。
  • Ds \ PriorityQueue :: peek - 返回队列前面的值。
  • Ds \ PriorityQueue :: pop - 删除并返回具有最高优先级的值。
  • Ds \ PriorityQueue :: push - 将值推入队列。
  • Ds \ PriorityQueue :: toArray - 将队列转换为数组。

← Ds\Queue::toArray

Ds\PriorityQueue::allocate →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com