Heap::...StrRev(3pm)

✨ NAME ✨

Heap::Elem::StrRev β€” Reversed String Heap Elements πŸ’…

okay so bestie, this is Heap::Elem::StrRev from the Perl docs, and it's giving exactly what it says on the tin πŸŽ€


🌸 SYNOPSIS 🌸

use Heap::Elem::StrRev( StrRElem );
use Heap::Fibonacci;

my $heap = Heap::Fibonacci->new;
my $elem;

foreach $i ( 'aa'..'bz' ) {
    $elem = StrRElem( $i );
    $heap->add( $elem );
}

while( defined( $elem = $heap->extract_top ) ) {
    print "Largest is ", $elem->val, "\n";
}

πŸ¦‹ DESCRIPTION πŸ¦‹

Heap::Elem::StrRev wraps string values into an element that a heap can manage, no cap. 🫢

The top of the heap will have the largest element still remaining. So yeah, it flips the vibe β€” instead of smallest-first, you get biggest-first, and it's iconic for that.

Not me casually pointing out: if you actually want the heap to always hand you the smallest element, go check out Heap::Elem::Str, which is right there in the SEE ALSO πŸ’–

The deets of the Elem interface? Those live in Heap::Elem, described in full, no gatekeeping.

And the deets of using a Heap interface? Those are described in Heap. respectfully, go read them, they ate. πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

John Macdonald, john@perlwolf.com


Copyright 1998-2007, O'Reilly & Associates.

This code is distributed under the same copyright terms as perl itself.


🌈 SEE ALSO 🌈


and that's the whole page, bestie, we're done πŸ’œ this was pulled from perl v5.36.0, dated 2022-10-22 β€” slay, periodt. ✨

πŸ“¦ where this page comes from