Lines Matching refs:heap

88  * need for the L_CODES extra codes used during heap construction. However
425 /* Index within the heap array of least frequent node in the Huffman tree */
429 * Remove the smallest element from the heap and recreate the heap with
430 * one less element. Updates heap and heap_len.
434 top = s->heap[SMALLEST]; \
435 s->heap[SMALLEST] = s->heap[s->heap_len--]; \
448 * Restore the heap property by moving down the tree starting at node k,
450 * when the heap property is re-established (each father smaller than its
458 int v = s->heap[k];
463 smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
467 if (smaller(tree, v, s->heap[j], s->depth)) break;
470 s->heap[k] = s->heap[j]; k = j;
475 s->heap[k] = v;
481 * IN assertion: the fields freq and dad are set, heap[heap_max] and
498 int h; /* heap index */
510 tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
513 n = s->heap[h];
554 m = s->heap[--h];
624 int n, m; /* iterate over heap elements */
628 /* Construct the initial heap, with least frequent element in
629 * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
630 * heap[0] is not used.
636 s->heap[++(s->heap_len)] = max_code = n;
649 node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
657 /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
668 m = s->heap[SMALLEST]; /* m = node of next least frequency */
670 s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
671 s->heap[--(s->heap_max)] = m;
684 /* and insert the new node in the heap */
685 s->heap[SMALLEST] = node++;
690 s->heap[--(s->heap_max)] = s->heap[SMALLEST];