类 Heap<E>
- java.lang.Object
-
- xin.manong.weapon.base.collection.Heap<E>
-
-
构造器概要
构造器 构造器 说明 Heap()Heap(int initCapacity, Comparator<? super E> comparator)Heap(Collection<E> collection)Heap(Collection<E> collection, Comparator<? super E> comparator)Heap(Comparator<? super E> comparator)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidadd(E e)添加元素booleanisEmpty()堆是否为空Iterator<E>iterator()数据迭代器Epeek()获取堆顶元素 完成操作后不影响堆元素Epoll()弹出堆顶元素 完成操作后移除堆顶元素booleanremove(E e)移除元素intsize()元素数量StringtoString()-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
从接口继承的方法 java.lang.Iterable
forEach, spliterator
-
-
-
-
构造器详细资料
-
Heap
public Heap()
-
Heap
public Heap(Comparator<? super E> comparator)
-
Heap
public Heap(int initCapacity, Comparator<? super E> comparator)
-
Heap
public Heap(Collection<E> collection)
-
Heap
public Heap(Collection<E> collection, Comparator<? super E> comparator)
-
-
方法详细资料
-
add
public void add(E e)
添加元素- 参数:
e- 元素,元素为空抛出异常IllegalArgumentException
-
peek
public E peek()
获取堆顶元素 完成操作后不影响堆元素- 返回:
- 堆顶元素,如果堆为空返回null
-
poll
public E poll()
弹出堆顶元素 完成操作后移除堆顶元素- 返回:
- 堆顶元素,如果堆为空返回null
-
remove
public boolean remove(E e)
移除元素- 参数:
e- 元素,元素为空抛出异常IllegalArgumentException- 返回:
- 移除成功返回true,否则返回false
-
size
public int size()
元素数量- 返回:
- 当前堆元素数量
-
isEmpty
public boolean isEmpty()
堆是否为空- 返回:
- 为空返回true,否则返回false
-
-