/** * adds the value to the heap. * * @param i the index * @param d the distance * @throws Exception if the heap gets too large */ public void put(int i, double d) throws Exception { if ((m_heap[0].index + 1) > (m_heap.length - 1)) { throw new Exception("the number of elements cannot exceed the " + "initially set maximum limit"); } m_heap[0].index++; m_heap[m_heap[0].index] = new MyHeapElement(i, d); upheap(); }
/** * adds the value to the heap. * * @param i the index * @param d the distance * @throws Exception if the heap gets too large */ public void put(int i, double d) throws Exception { if ((m_heap[0].index + 1) > (m_heap.length - 1)) { throw new Exception("the number of elements cannot exceed the " + "initially set maximum limit"); } m_heap[0].index++; m_heap[m_heap[0].index] = new MyHeapElement(i, d); upheap(); }