|
Lines 744-750
Link Here
|
| 744 |
//heap must be empty |
744 |
//heap must be empty |
| 745 |
assert(this->size()==0); |
745 |
assert(this->size()==0); |
| 746 |
for (i = 0; !full() && i<n; i++) { |
746 |
for (i = 0; !full() && i<n; i++) { |
| 747 |
insert(arr[i]); |
747 |
this->insert(arr[i]); |
| 748 |
} |
748 |
} |
| 749 |
if (i < n) { |
749 |
if (i < n) { |
| 750 |
assert(i == this->maxsize); |
750 |
assert(i == this->maxsize); |
|
Lines 777-789
Link Here
|
| 777 |
|
777 |
|
| 778 |
if(old) { |
778 |
if(old) { |
| 779 |
HeapIndex n = this->size(); |
779 |
HeapIndex n = this->size(); |
| 780 |
this->A = allocateHeap(this->maxsize); /* allocate a new array */ |
780 |
this->A = this->allocateHeap(this->maxsize); /* allocate a new array */ |
| 781 |
/* copy over the old values */ |
781 |
/* copy over the old values */ |
| 782 |
assert(this->maxsize > n); |
782 |
assert(this->maxsize > n); |
| 783 |
for(HeapIndex i=0; i<=n; i++) { /* why extra value? -RW */ |
783 |
for(HeapIndex i=0; i<=n; i++) { /* why extra value? -RW */ |
| 784 |
this->A[i] = old[i]; |
784 |
this->A[i] = old[i]; |
| 785 |
} |
785 |
} |
| 786 |
freeHeap(old); /* free up old storage */ |
786 |
this->freeHeap(old); /* free up old storage */ |
| 787 |
} |
787 |
} |
| 788 |
|
788 |
|
| 789 |
} |
789 |
} |