All pastes #344820 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-08 01:10 UTC
rendered paste body
public class TernaryHeap<E extends Comparable<E>> {

        private E[] heapArray;


        /**
         * Empty heap constructor
         */

        public TernaryHeap(E[] init) {
                heapArray = init;
        }

        /**
         * Returns the number of items in the heap.
         *
         * @return      Size of the heap
         */

        public int size() {
                int size=0;

                for(int i=0; i<=heapArray.length;i++) {
                        if(heapArray[i] != null) {
                                size++;
                        }
                }      

                return size;
        }

        /**
         * Insert an item into the heap.
         *
         * @param       Item    item to insert
         */

        public void insert(E item) {
                //if(this.size() >= heapArray.length) {
                int compare;  
 
                for (int i=0; i<=heapArray.length;i++) {  
                        a[heapArray.length]=item;
                        if(heapArray[i]   
                              


        }

        /**
         * Remove and return the item at the root of the heap.
         *
         * @return      the smallest item in the heap.
         * @exception   UnderflowException      If the heap is empty
         */

        public E remove() {
        }

        /**
         * Returns the String representation of the heap for testing. This
         * consists of each element's String representation on a line by
         * itself, in order reading across each level of the heap from top 
         * to bottom
         * 
         * @return      the String representation of the heap
         */

        public String toString() {
        }

} //TernaryHeap