public class FixedCapacityLongLongMinHeap extends Object implements Long2LongMapEntryIterable
Constructor and Description |
---|
FixedCapacityLongLongMinHeap(int capacity)
Initialize the heap with desired capacity
|
Modifier and Type | Method and Description |
---|---|
void |
add(long key,
long value)
Add a key value pair
|
void |
clear()
Clear the heap
|
protected int |
compare(long key1,
long value1,
long key2,
long value2)
Comapre two (key, value) entries
|
void |
forEachLongLong(LongLongConsumer f)
Traverse all elements of the heap, calling given function on each element.
|
boolean |
forEachWhileLongLong(LongLongPredicate f)
Traverse all elements of the heap, calling given function on each element,
or until predicate returns false.
|
int |
getCapacity()
Get capacity of the heap
|
long |
getMinKey() |
long |
getMinValue() |
boolean |
isEmpty()
Check if the heap is empty
|
it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.longs.Long2LongMap.Entry> |
iterator()
Get the iterator.
|
static FixedCapacityLongLongMinHeap |
read(FixedCapacityLongLongMinHeap heap,
DataInput in)
Deserializes an object from data input.
|
void |
removeMin()
Removes the (key, value) pair that corresponds to the minimum value
currently in the heap.
|
int |
size()
Get the size of this iterable
|
static void |
write(FixedCapacityLongLongMinHeap heap,
DataOutput out)
Serializes an object into data output.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public FixedCapacityLongLongMinHeap(int capacity)
capacity
- Capacitypublic void clear()
public void add(long key, long value)
key
- Keyvalue
- Valuepublic long getMinKey()
NoSuchElementException
- if the heap is empty.public long getMinValue()
NoSuchElementException
- if the heap is empty.public void removeMin()
protected int compare(long key1, long value1, long key2, long value2)
key1
- First keyvalue1
- First valuekey2
- Second keyvalue2
- Second valuepublic it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.longs.Long2LongMap.Entry> iterator()
Long2LongMapEntryIterable
iterator
in interface it.unimi.dsi.fastutil.objects.ObjectIterable<it.unimi.dsi.fastutil.longs.Long2LongMap.Entry>
iterator
in interface Iterable<it.unimi.dsi.fastutil.longs.Long2LongMap.Entry>
iterator
in interface Long2LongMapEntryIterable
public int size()
Long2LongMapEntryIterable
size
in interface Long2LongMapEntryIterable
public boolean isEmpty()
public int getCapacity()
public static void write(FixedCapacityLongLongMinHeap heap, DataOutput out) throws IOException
heap
- Object instance to serializeout
- Data outputIOException
public static FixedCapacityLongLongMinHeap read(FixedCapacityLongLongMinHeap heap, DataInput in) throws IOException
heap
- Object to reuse if possiblein
- Data inputIOException
public void forEachLongLong(LongLongConsumer f)
f
- Function to call on each element.public boolean forEachWhileLongLong(LongLongPredicate f)
f
- Function to call on each element.Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.