【Java】优先队列PriorityQueue

1.构造函数

PriorityQueue()
Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their natural ordering.
PriorityQueue(Collection<? extends E> c)
Creates a PriorityQueue containing the elements in the specified collection.
PriorityQueue(int initialCapacity)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to their natural ordering.
PriorityQueue(int initialCapacity, Comparator<? super E> comparator)
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.
PriorityQueue(PriorityQueue<? extends E> c)
Creates a PriorityQueue containing the elements in the specified priority queue.
PriorityQueue(SortedSet<? extends E> c)
Creates a PriorityQueue containing the elements in the specified sorted set.

2.方法摘要


booleanadd(E e)
Inserts the specified element into this priority queue.
voidclear()
Removes all of the elements from this priority queue.
Comparator<? super E>comparator()
Returns the comparator used to order the elements in this queue, or null if this queue is sorted according to the natural ordering of its elements.
booleancontains(Object o)
Returns true if this queue contains the specified element.
Iterator<E>iterator()
Returns an iterator over the elements in this queue.
booleanoffer(E e)
Inserts the specified element into this priority queue.
Epeek()
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
Epoll()
Retrieves and removes the head of this queue, or returns null if this queue is empty.
booleanremove(Object o)
Removes a single instance of the specified element from this queue, if it is present.
intsize()
Returns the number of elements in this collection.
Object[]toArray()
Returns an array containing all of the elements in this queue.
<T> T[]toArray(T[] a)
Returns an array containing all of the elements in this queue; the runtime type of the returned array is that of the specified

3.程序实例

待续



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值