public class FixedCapacityLongIntMinHeap extends Object implements Long2IntMapEntryIterable
| Constructor and Description |
|---|
FixedCapacityLongIntMinHeap(int capacity)
Initialize the heap with desired capacity
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(long key,
int value)
Add a key value pair
|
void |
clear()
Clear the heap
|
protected int |
compare(long key1,
int value1,
long key2,
int value2)
Comapre two (key, value) entries
|
void |
forEachLongInt(LongIntConsumer f)
Traverse all elements of the heap, calling given function on each element.
|
boolean |
forEachWhileLongInt(LongIntPredicate 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() |
int |
getMinValue() |
boolean |
isEmpty()
Check if the heap is empty
|
it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.longs.Long2IntMap.Entry> |
iterator()
Get the iterator.
|
static FixedCapacityLongIntMinHeap |
read(FixedCapacityLongIntMinHeap 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(FixedCapacityLongIntMinHeap heap,
DataOutput out)
Serializes an object into data output.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic FixedCapacityLongIntMinHeap(int capacity)
capacity - Capacitypublic void clear()
public void add(long key,
int value)
key - Keyvalue - Valuepublic long getMinKey()
NoSuchElementException - if the heap is empty.public int getMinValue()
NoSuchElementException - if the heap is empty.public void removeMin()
protected int compare(long key1,
int value1,
long key2,
int value2)
key1 - First keyvalue1 - First valuekey2 - Second keyvalue2 - Second valuepublic it.unimi.dsi.fastutil.objects.ObjectIterator<it.unimi.dsi.fastutil.longs.Long2IntMap.Entry> iterator()
Long2IntMapEntryIterableiterator in interface it.unimi.dsi.fastutil.objects.ObjectIterable<it.unimi.dsi.fastutil.longs.Long2IntMap.Entry>iterator in interface Iterable<it.unimi.dsi.fastutil.longs.Long2IntMap.Entry>iterator in interface Long2IntMapEntryIterablepublic int size()
Long2IntMapEntryIterablesize in interface Long2IntMapEntryIterablepublic boolean isEmpty()
public int getCapacity()
public static void write(FixedCapacityLongIntMinHeap heap, DataOutput out) throws IOException
heap - Object instance to serializeout - Data outputIOExceptionpublic static FixedCapacityLongIntMinHeap read(FixedCapacityLongIntMinHeap heap, DataInput in) throws IOException
heap - Object to reuse if possiblein - Data inputIOExceptionpublic void forEachLongInt(LongIntConsumer f)
f - Function to call on each element.public boolean forEachWhileLongInt(LongIntPredicate f)
f - Function to call on each element.Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.