bool Heap::insert(Node *no) { /* O(lg n) */ if (this->size < this->max) { this->heap[this->size] = no; heapifyup(this->size); this->size++; return true; } return false; }
void NHeap<T>::update(T t,unsigned newKey)//newKey < key! { for(unsigned i=0;i<occupation;i++) { if(heap[i].element == t) { heap[i].key = newKey; heapifyup(i); break; } } }
void NHeap<T>::insert(T t,unsigned key) { //printf("Inserting %d\n",key); if(occupation<capacity) { heap[occupation].key = key; heap[occupation].element = t; heapifyup(occupation++); } else { if(resize(2*capacity) == 0) { heap[occupation].key = key; heap[occupation].element = t; heapifyup(occupation++); } else { printf("N-Heap memory allocation error\n"); } } }