Heap::Elem::Num(3pm)
π Heap::Elem::Num β the perl manual page, but make it bestie β¨
okay so this is Heap::Elem::Num(3pm), straight out of the User Contributed Perl Documentation, and it's literally just numeric heap elements π
πΈ NAME πΈ
Heap::Elem::Num β Numeric Heap Elements. that's it, that's the whole name, slay π
β¨ SYNOPSIS β¨
here's the vibe, copy-paste ready, no cap:
use Heap::Elem::Num( NumElem );
use Heap::Fibonacci;
my $heap = Heap::Fibonacci->new;
my $elem;
foreach $i ( 1..100 ) {
$elem = NumElem( $i );
$heap->add( $elem );
}
while( defined( $elem = $heap->extract_top ) ) {
print "Smallest is ", $elem->val, "\n";
}
look at her go π¦ making a heap, yeeting 100 numbers in, pulling them back out smallest-first. main character energy fr fr.
π DESCRIPTION π
so Heap::Elem::Num is the little wrapper that takes a plain numeric value and dresses it up as an element so a heap can manage it π«Ά like, the number needs a glow-up to hang out on the heap, and this module is the stylist.
the top of the heap will have the smallest element still remaining. yes, smallest, that's the whole point bestie, min-heap behaviour, periodt π
π heads up: if you actually wanted the largest element to come out first, go look at Heap::Elem::NumRev instead. don't come for me, that's just how it is.
the deets of the Elem interface itself? those live over in Heap::Elem β go read that if you want the full lore.
and the deets of actually using a Heap interface? those are in Heap. go read that one too.
π AUTHOR π
John Macdonald, john@perlwolf.com β shoutout to the legend who wrote this, we love you, we stan π
π COPYRIGHT π
Copyright 1998-2007, O'Reilly & Associates.
This code is distributed under the same copyright terms as perl itself. (iykyk, same terms as perl, that's the whole deal β¨)
π₯ SEE ALSO π₯
one last thing bestie β grab the smallest, not the biggest. if you wanted biggest you're in the wrong manpage and I will be sending you to Heap::Elem::NumRev(3) π
and that's a wrap on this lil page π it's from perl v5.36.0, dated 2022-10-22, and it lives at Heap::Elem::Num(3pm). love that for her. mwah π«Ά
π¦ where this page comes from
- ubuntu noble: libheap-perl 0.80-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libheap-perl 0.80-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libheap-perl 0.80-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms