1Heap::Elem::RefRev(3) User Contributed Perl DocumentationHeap::Elem::RefRev(3)
2
3
4

NAME

6       Heap::Elem::RefRev - Reversed Object Reverence Heap Elements
7

SYNOPSIS

9         use Heap::Elem::RefRev( RefRElem );
10         use Heap::Fibonacci;
11
12         my $heap = Heap::Fibonacci->new;
13         my $elem;
14
15         foreach $i ( 1..100 ) {
16             $obj = myObject->new( $i );
17             $elem = RefRElem( $obj );
18             $heap->add( $elem );
19         }
20
21         while( defined( $elem = $heap->extract_top ) ) {
22             # assume that myObject object have a method I<printable>
23             print "Largest is ", $elem->val->printable, "\n";
24         }
25

DESCRIPTION

27       Heap::Elem::RefRev is used to wrap object reference values into an
28       element that can be managed on a heap.  Each referenced object must
29       have a method cmp which can compare itself with any of the other
30       objects that have references on the same heap.  These comparisons must
31       be consistant with normal arithmetic.  The top of the heap will have
32       the largest (according to cmp) element still remaining.  (See
33       Heap::Elem::Ref if you want the heap to always return the smallest
34       element.)
35
36       The details of the Elem interface are described in Heap::Elem.
37
38       The details of using a Heap interface are described in Heap.
39

AUTHOR

41       John Macdonald, john@perlwolf.com
42
44       Copyright 1998-2007, O'Reilly & Associates.
45
46       This code is distributed under the same copyright terms as perl itself.
47

SEE ALSO

49       Heap(3), Heap::Elem(3), Heap::Elem::Ref(3).
50
51
52
53perl v5.32.0                      2020-07-28             Heap::Elem::RefRev(3)
Impressum