Catalano.Core.Structs
Class BinaryHeap<E extends java.lang.Comparable<E>>
- java.lang.Object
-
- Catalano.Core.Structs.BinaryHeap<E>
-
- Type Parameters:
E- Item.
public class BinaryHeap<E extends java.lang.Comparable<E>> extends java.lang.ObjectBinary Heap.
-
-
Constructor Summary
Constructors Constructor and Description BinaryHeap()Initializes a new instance of the BinaryHeap class.BinaryHeap(E[] keys)Initializes a new instance of the BinaryHeap class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(E node)Adds an item in the heap.intcount()Get the count actually in the heap.booleanisEmpty()Check if the heap is empty.Emin()Get the minimum item from the heap.Eremove()Remove the last node from the heap.voidremove(E item)Remove a specified item from the heap.intsize()Get the size of the heap.
-
-
-
Constructor Detail
-
BinaryHeap
public BinaryHeap()
Initializes a new instance of the BinaryHeap class.
-
BinaryHeap
public BinaryHeap(E[] keys)
Initializes a new instance of the BinaryHeap class.- Parameters:
keys- Items.
-
-
Method Detail
-
count
public int count()
Get the count actually in the heap.- Returns:
- Count.
-
size
public int size()
Get the size of the heap.- Returns:
- Size.
-
add
public void add(E node)
Adds an item in the heap.- Parameters:
node- Item as node.
-
remove
public E remove()
Remove the last node from the heap.- Returns:
- Item from the last node.
-
remove
public void remove(E item)
Remove a specified item from the heap.- Parameters:
item- Item.
-
min
public E min()
Get the minimum item from the heap.- Returns:
- Item.
-
isEmpty
public boolean isEmpty()
Check if the heap is empty.- Returns:
- True if the heap is empty, otherwise false.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG