Lines Matching refs:heap

119  * need for the L_CODES extra codes used during heap construction. However
454 /* Index within the heap array of least frequent node in the Huffman tree */
458 * Remove the smallest element from the heap and recreate the heap with
459 * one less element. Updates heap and heap_len.
463 top = s->heap[SMALLEST]; \
464 s->heap[SMALLEST] = s->heap[s->heap_len--]; \
477 * Restore the heap property by moving down the tree starting at node k,
479 * when the heap property is re-established (each father smaller than its
487 int v = s->heap[k];
492 smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
496 if (smaller(tree, v, s->heap[j], s->depth)) break;
499 s->heap[k] = s->heap[j]; k = j;
504 s->heap[k] = v;
510 * IN assertion: the fields freq and dad are set, heap[heap_max] and
527 int h; /* heap index */
539 tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
542 n = s->heap[h];
583 m = s->heap[--h];
653 int n, m; /* iterate over heap elements */
657 /* Construct the initial heap, with least frequent element in
658 * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
659 * heap[0] is not used.
665 s->heap[++(s->heap_len)] = max_code = n;
678 node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
686 /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
697 m = s->heap[SMALLEST]; /* m = node of next least frequency */
699 s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
700 s->heap[--(s->heap_max)] = m;
713 /* and insert the new node in the heap */
714 s->heap[SMALLEST] = node++;
719 s->heap[--(s->heap_max)] = s->heap[SMALLEST];