Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## dataStructures
Class MinHeap

    java.lang.Object
      |
      +--dataStructures.MinHeap

public class MinHeap
extends java.lang.Object
implements MinPriorityQueue

Constructor Summary
`MinHeap()` create a heap with initial capacity 10
`MinHeap(int initialCapacity)` create a heap with the given initial capacity

Method Summary
`java.lang.Comparable` | `getMin()`
`void` | `initialize(java.lang.Comparable[] theHeap, int theSize)` initialize min heap to element array theHeap
`boolean` | `isEmpty()`
`static void` | `main(java.lang.String[] args)` test program
`void` | `put(java.lang.Comparable theElement)` put theElement into the heap
`java.lang.Comparable` | `removeMin()` remove min element and return it
`int` | `size()`
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### MinHeap

    public MinHeap(int initialCapacity)

  create a heap with the given initial capacity
  Throws:
    java.lang.IllegalArgumentException - when initialCapacity < 1

### MinHeap

    public MinHeap()

  create a heap with initial capacity 10

Method Detail

### isEmpty

    public boolean isEmpty()

  Specified by:
    isEmpty in interface MinPriorityQueue
  Returns:
    true iff the heap is empty

### size

    public int size()

  Specified by:
    size in interface MinPriorityQueue
  Returns:
    number of elements in the heap

### getMin

    public java.lang.Comparable getMin()

  Specified by:
    getMin in interface MinPriorityQueue
  Returns:
    minimum element

### put

    public void put(java.lang.Comparable theElement)

  put theElement into the heap
  Specified by:
    put in interface MinPriorityQueue

### removeMin

    public java.lang.Comparable removeMin()

  remove min element and return it
  Specified by:
    removeMin in interface MinPriorityQueue

### initialize

    public void initialize(java.lang.Comparable[] theHeap,
                           int theSize)

  initialize min heap to element array theHeap

### toString

    public java.lang.String toString()

  Overrides:
    toString in class java.lang.Object

### main

    public static void main(java.lang.String[] args)

  test program

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD