Array-Heap

 view release on metacpan or  search on metacpan

Heap.xs  view on Meta::CPAN

MODULE = Array::Heap		PACKAGE = Array::Heap

void
make_heap (SV *heap)
        PROTOTYPE: \@
        ALIAS:
        make_heap_idx = 1
        CODE:
        make_heap (array (heap), cmp_nv, 0, ix);

void
make_heap_lex (SV *heap)
        PROTOTYPE: \@
        CODE:
        make_heap (array (heap), cmp_sv, 0, 0);

void
make_heap_cmp (SV *cmp, SV *heap)
        PROTOTYPE: &\@
        CODE:
{
        dCMP;
        CMP_PUSH (cmp);
        make_heap (array (heap), cmp_custom, cmp_data, 0);
        CMP_POP;
}

void
push_heap (SV *heap, ...)
        PROTOTYPE: \@@
        ALIAS:
        push_heap_idx = 1
        CODE:
        push_heap (array (heap), cmp_nv, 0, &(ST(1)), items - 1, ix);

void
push_heap_lex (SV *heap, ...)
        PROTOTYPE: \@@
        CODE:
        push_heap (array (heap), cmp_sv, 0, &(ST(1)), items - 1, 0);

void
push_heap_cmp (SV *cmp, SV *heap, ...)
        PROTOTYPE: &\@@
        CODE:
{
	SV **st_2 = &(ST(2)); /* multicall.h uses PUSHSTACK */
        dCMP;
        CMP_PUSH (cmp);
        push_heap (array (heap), cmp_custom, cmp_data, st_2, items - 2, 0);
        CMP_POP;
}

SV *
pop_heap (SV *heap)
        PROTOTYPE: \@
        ALIAS:
        pop_heap_idx = 1
        CODE:
        RETVAL = pop_heap (array (heap), cmp_nv, 0, ix);
        OUTPUT:
        RETVAL

SV *
pop_heap_lex (SV *heap)
        PROTOTYPE: \@
        CODE:
        RETVAL = pop_heap (array (heap), cmp_sv, 0, 0);
        OUTPUT:
        RETVAL

SV *
pop_heap_cmp (SV *cmp, SV *heap)
        PROTOTYPE: &\@
        CODE:
{
        dCMP;
        CMP_PUSH (cmp);
        RETVAL = pop_heap (array (heap), cmp_custom, cmp_data, 0);
        CMP_POP;
}
        OUTPUT:
        RETVAL

SV *
splice_heap (SV *heap, int idx)
        PROTOTYPE: \@$
        ALIAS:
        splice_heap_idx = 1
        CODE:
        RETVAL = splice_heap (array (heap), cmp_nv, 0, idx, ix);
        OUTPUT:
        RETVAL

SV *
splice_heap_lex (SV *heap, int idx)
        PROTOTYPE: \@$
        CODE:
        RETVAL = splice_heap (array (heap), cmp_sv, 0, idx, 0);
        OUTPUT:
        RETVAL

SV *
splice_heap_cmp (SV *cmp, SV *heap, int idx)
        PROTOTYPE: &\@$
        CODE:
{
        dCMP;
        CMP_PUSH (cmp);
        RETVAL = splice_heap (array (heap), cmp_custom, cmp_data, idx, 0);
        CMP_POP;
}
        OUTPUT:
        RETVAL

void
adjust_heap (SV *heap, int idx)
        PROTOTYPE: \@$
        ALIAS:
        adjust_heap_idx = 1
        CODE:
        adjust_heap (array (heap), cmp_nv, 0, idx, ix);

void
adjust_heap_lex (SV *heap, int idx)
        PROTOTYPE: \@$
        CODE:
        adjust_heap (array (heap), cmp_sv, 0, idx, 0);

void
adjust_heap_cmp (SV *cmp, SV *heap, int idx)
        PROTOTYPE: &\@$
        CODE:
{
        dCMP;
        CMP_PUSH (cmp);
        adjust_heap (array (heap), cmp_custom, cmp_data, idx, 0);
        CMP_POP;
}



( run in 2.580 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )