Class LseMinHeap
java.lang.Object
gov.nih.mipav.model.algorithms.levelset.LseMinHeap
A class that encapsules a min-heap data structure. The minimum value of a set of numbers is guaranteed always to be at the root of the heap.
- Version:
- 0.1 November 7, 2006
- Author:
- David Eberly
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassEach heap record stores a numeric value, the index of the record within the records array, and a generator which acts as an identifier for the application to use to store information about how the numeric value was generated in the application. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) LseMinHeap.Record[]The record storage for the heap, allocated in one large chunk.(package private) intThe number of active records in the heap. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intGet the current number of active heap records.final LseMinHeap.RecordgetRecord(int i) Get a record from the heap records.final LseMinHeap.Recordinsert(int iGenerator, float fValue) Insert a numeric value into the min-heap data structure.final LseMinHeap.Recordremove()Remove the root of the heap.final voidupdate(LseMinHeap.Record kRecord, float fValue) The value of a heap record must be modified through this function call.
-
Field Details
-
m_iQuantity
int m_iQuantityThe number of active records in the heap. -
m_akRecords
LseMinHeap.Record[] m_akRecordsThe record storage for the heap, allocated in one large chunk.
-
-
Constructor Details
-
LseMinHeap
public LseMinHeap(int iMaxQuantity) Create a new min-heap data structure.- Parameters:
iMaxQuantity- The maximum number of heap records. This number depends on the application's needs.
-
-
Method Details
-
getQuantity
public final int getQuantity()Get the current number of active heap records.- Returns:
- The current number of active heap records.
-
getRecord
Get a record from the heap records.- Parameters:
i- The index of the desired record.- Returns:
- The desired record.
-
insert
Insert a numeric value into the min-heap data structure.- Parameters:
iGenerator- The application-specific identifier that is associated with the numeric value managed by the heap record.fValue- The numeric value managed by the heap record.- Returns:
- The heap record that manages the numeric value.
-
remove
Remove the root of the heap. The root contains the minimum value of all heap elements.- Returns:
- The record that corresponded to the root of the heap.
-
update
The value of a heap record must be modified through this function call. The side effect is that the heap must be updated accordingly to accommodate the new value.- Parameters:
kRecord- The record to be updated.fValue- The record's new numeric value.
-