Package org.jheaps.monotone
Class BigIntegerRadixAddressableHeap<V>
- java.lang.Object
-
- org.jheaps.monotone.AbstractRadixAddressableHeap<java.math.BigInteger,V>
-
- org.jheaps.monotone.BigIntegerRadixAddressableHeap<V>
-
- Type Parameters:
V- the type of values maintained by this heap
- All Implemented Interfaces:
java.io.Serializable,AddressableHeap<java.math.BigInteger,V>
public class BigIntegerRadixAddressableHeap<V> extends AbstractRadixAddressableHeap<java.math.BigInteger,V>
An addressable radix heap forBigIntegerkeys. The heap storesBigIntegerkeys sorted according to the natural ordering of its keys. A radix heap is a monotone heap, especially designed for algorithms (such as Dijkstra) which scan elements in order of nondecreasing keys.The implementation use arrays in order to store the elements. Operations
insertandfindMinare worst-case constant time. The cost of operationdeleteMinis amortized O(logC) assuming the radix-heap contains keys in the range [0, C] or equivalently [a,a+C].Note that this implementation is not synchronized. If multiple threads access a heap concurrently, and at least one of the threads modifies the heap structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more elements or changing the key of some element.) This is typically accomplished by synchronizing on some object that naturally encapsulates the heap.
- See Also:
AddressableHeap, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jheaps.monotone.AbstractRadixAddressableHeap
AbstractRadixAddressableHeap.Node
-
Nested classes/interfaces inherited from interface org.jheaps.AddressableHeap
AddressableHeap.Handle<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID-
Fields inherited from class org.jheaps.monotone.AbstractRadixAddressableHeap
buckets, currentMin, EMPTY, lastDeletedKey, maxKey, minKey, size
-
-
Constructor Summary
Constructors Constructor Description BigIntegerRadixAddressableHeap(java.math.BigInteger minKey, java.math.BigInteger maxKey)Constructs a new heap which can store values between a minimum and a maximum key value (inclusive).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcompare(java.math.BigInteger o1, java.math.BigInteger o2)Compares its two arguments for order.protected intmsd(java.math.BigInteger a, java.math.BigInteger b)Compute the most significant digit which is different in the binary representation of two values, or -1 if numbers are equal.-
Methods inherited from class org.jheaps.monotone.AbstractRadixAddressableHeap
clear, comparator, computeBucket, deleteMin, findMin, insert, insert, isEmpty, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BigIntegerRadixAddressableHeap
public BigIntegerRadixAddressableHeap(java.math.BigInteger minKey, java.math.BigInteger maxKey)Constructs a new heap which can store values between a minimum and a maximum key value (inclusive). It is important to use the smallest key range as the heap uses O(logC) where C=maxKey-minKey+1 buckets to store elements. Moreover, the operationdeleteMinrequires amortized O(logC) time.- Parameters:
minKey- the non-negative minimum key that this heap supports (inclusive)maxKey- the maximum key that this heap supports (inclusive)- Throws:
java.lang.IllegalArgumentException- if the minimum key is negativejava.lang.IllegalArgumentException- if the maximum key is less than the minimum key
-
-
Method Detail
-
compare
protected int compare(java.math.BigInteger o1, java.math.BigInteger o2)Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.- Specified by:
comparein classAbstractRadixAddressableHeap<java.math.BigInteger,V>- Parameters:
o1- the first object to be compared.o2- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-
msd
protected int msd(java.math.BigInteger a, java.math.BigInteger b)Compute the most significant digit which is different in the binary representation of two values, or -1 if numbers are equal.- Specified by:
msdin classAbstractRadixAddressableHeap<java.math.BigInteger,V>- Parameters:
a- the first valueb- the second value- Returns:
- the most significant digit which is different or -1 if numbers are equal
-
-