Heap::Elem::Str(3pm)

πŸ’– NAME πŸ’–

Heap::Elem::Str β€” String Heap Elements (yes bestie, that's the whole name, we're keeping it)


✨ SYNOPSIS ✨

use Heap::Elem::Str( StrElem );
use Heap::Fibonacci;

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

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

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so Heap::Elem::Str is literally just here to wrap your string values up all cozy into an element that a heap can actually manage, bestie. That's it. That's the job. 🫢

The top of the heap is gonna be the smallest element still remaining β€” so if you're pulling things out, smallest first, every single time. Periodt.

Not me dropping this important lil note: if you want the heap to always return the largest element instead, go look at Heap::Elem::StrRev. Iykyk. πŸ’…

And if you wanna know how the whole Elem interface works under the hood, all the deets are in Heap::Elem.

Same energy for actually using a Heap interface β€” that whole situation is described in Heap. Go read it, it's giving essential. πŸ‘‘


🌸 AUTHOR 🌸

John Macdonald, john@perlwolf.com β€” credit where credit is due, icon behavior. ✨


Copyright 1998-2007, O'Reilly & Associates.

This code is distributed under the same copyright terms as perl itself. (Fr fr, same terms, no cap. πŸ“œ)


πŸŽ€ SEE ALSO πŸŽ€


That's the whole vibe check, bestie β€” this was Heap::Elem::Str(3pm) from perl v5.36.0, dated 2022-10-22. Go slay some heaps. πŸ’–πŸŒˆβ­

πŸ“¦ where this page comes from