Lines Matching refs:heap
88 * need for the L_CODES extra codes used during heap construction. However
496 /* Index within the heap array of least frequent node in the Huffman tree */
500 * Remove the smallest element from the heap and recreate the heap with
501 * one less element. Updates heap and heap_len.
505 top = s->heap[SMALLEST]; \
506 s->heap[SMALLEST] = s->heap[s->heap_len--]; \
519 * Restore the heap property by moving down the tree starting at node k,
521 * when the heap property is re-established (each father smaller than its
526 int v = s->heap[k];
531 smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) {
535 if (smaller(tree, v, s->heap[j], s->depth)) break;
538 s->heap[k] = s->heap[j]; k = j;
543 s->heap[k] = v;
549 * IN assertion: the fields freq and dad are set, heap[heap_max] and
564 int h; /* heap index */
576 tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
579 n = s->heap[h];
620 m = s->heap[--h];
649 int n, m; /* iterate over heap elements */
653 /* Construct the initial heap, with least frequent element in
654 * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1].
655 * heap[0] is not used.
661 s->heap[++(s->heap_len)] = max_code = n;
674 node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
682 /* The elements heap[heap_len/2 + 1 .. heap_len] are leaves of the tree,
693 m = s->heap[SMALLEST]; /* m = node of next least frequency */
695 s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
696 s->heap[--(s->heap_max)] = m;
709 /* and insert the new node in the heap */
710 s->heap[SMALLEST] = node++;
715 s->heap[--(s->heap_max)] = s->heap[SMALLEST];