Lines Matching refs:heap

317 /* maximum heap size */
486 int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
487 int heap_len; /* number of elements in the heap */
490 * The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0]
491 * is not used. The same heap array is used to build all
2308 * is no need for the L_CODES extra codes used during heap
2588 /* Index within the heap array of least frequent node in the Huffman tree */
2593 * Remove the smallest element from the heap and recreate the heap with
2594 * one less element. Updates heap and heap_len.
2598 top = s->heap[SMALLEST]; \
2599 s->heap[SMALLEST] = s->heap[s->heap_len--]; \
2613 * Restore the heap property by moving down the tree starting at node k,
2615 * when the heap property is re-established (each father smaller than its
2624 int v = s->heap[k];
2629 smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
2633 if (smaller(tree, v, s->heap[j], s->depth)) break;
2636 s->heap[k] = s->heap[j]; k = j;
2641 s->heap[k] = v;
2648 * IN assertion: the fields freq and dad are set, heap[heap_max] and
2666 int h; /* heap index */
2680 tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
2683 n = s->heap[h];
2730 m = s->heap[--h];
2810 int n, m; /* iterate over heap elements */
2815 * Construct the initial heap, with least frequent element in
2816 * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and
2817 * heap[2*n+1]. heap[0] is not used.
2823 s->heap[++(s->heap_len)] = max_code = n;
2837 node = s->heap[++(s->heap_len)] = (max_code < 2 ?
2847 * The elements heap[heap_len/2+1 .. heap_len] are leaves of
2859 m = s->heap[SMALLEST]; /* m = node of next least frequency */
2862 s->heap[--(s->heap_max)] = n;
2863 s->heap[--(s->heap_max)] = m;
2876 /* and insert the new node in the heap */
2877 s->heap[SMALLEST] = node++;
2882 s->heap[--(s->heap_max)] = s->heap[SMALLEST];