public class LongPriorityQueue extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
currentCapacity |
protected long[] |
heap |
protected int |
maxSize |
protected long |
sentinel |
protected int |
size |
Constructor and Description |
---|
LongPriorityQueue(int initialSize,
int maxSize,
long sentinel) |
Modifier and Type | Method and Description |
---|---|
long |
add(long element)
Adds an object to a PriorityQueue in log(size) time.
|
void |
addNoCheck(long element)
Adds an object to a PriorityQueue in log(size) time.
|
void |
clear()
Removes all entries from the PriorityQueue.
|
int |
getCurrentCapacity() |
long[] |
getInternalArray()
Returns the array used to hold the heap, with the smallest item at array[1]
and the last (but not necessarily largest) at array[size()].
|
protected void |
initialize(int sz) |
boolean |
insert(long element)
inserts the element and returns true if this element caused another element
to be dropped from the queue.
|
long |
insertWithOverflow(long element)
Adds an object to a PriorityQueue in log(size) time.
|
long |
pop()
Removes and returns the least element of the PriorityQueue in log(size)
time.
|
void |
resize(int sz) |
int |
size()
Returns the number of elements currently stored in the PriorityQueue.
|
long[] |
sort(int n)
Pops the smallest n items from the heap, placing them in the internal array at
arr[size] through arr[size-(n-1)] with the smallest (first element popped)
being at arr[size].
|
long |
top()
Returns the least element of the PriorityQueue in constant time.
|
long |
updateTop()
Should be called when the Object at top changes values.
|
protected int size
protected int currentCapacity
protected int maxSize
protected long[] heap
protected final long sentinel
public LongPriorityQueue(int initialSize, int maxSize, long sentinel)
protected void initialize(int sz)
public int getCurrentCapacity()
public void resize(int sz)
public long add(long element)
ArrayIndexOutOfBoundsException
is thrown.public void addNoCheck(long element)
ArrayIndexOutOfBoundsException
is thrown.public long insertWithOverflow(long element)
public boolean insert(long element)
public long top()
public long pop()
public long updateTop()
public int size()
public long[] getInternalArray()
public long[] sort(int n)
public void clear()
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.