zoukankan      html  css  js  c++  java
  • PriorityQueue

    优先级队列

    1、无限的

    2、不允许null

    3、在构造queue或者元素需要实现comparable接口

    4、数据结构是堆,而且是极小堆。存储是数组。

    An unbounded priority queue based on a priority heap. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used. A priority queue does not permit null elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so may result in ClassCastException).

    Implementation note: this implementation provides O(log(n)) time for the enqueing and dequeing methods (offerpollremove() and add); linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peekelement, and size).

    "a".compareTo("b")=-1;

    "a".compareTo("ab")=-1;

  • 相关阅读:
    Flesch Reading Ease (poj 3371)
    保留道路
    列车调度
    三角形
    高精度加法
    AC自动机(1)
    线段树
    并查集(3)
    并查集(2)
    并查集
  • 原文地址:https://www.cnblogs.com/YDDMAX/p/5644019.html
Copyright © 2011-2022 走看看