{"id":20315230,"url":"https://github.com/sysread/skewheap-pp","last_synced_at":"2025-08-02T08:39:12.155Z","repository":{"id":56833673,"uuid":"274161989","full_name":"sysread/SkewHeap-PP","owner":"sysread","description":"A fast and flexible heap structure written in pure perl","archived":false,"fork":false,"pushed_at":"2020-07-06T19:57:08.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T11:24:05.996Z","etag":null,"topics":["data-structures","heap","perl","perl5","prioity-queue","queue","skew","skewheap"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysread.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-22T14:37:21.000Z","updated_at":"2020-07-07T17:01:46.000Z","dependencies_parsed_at":"2022-09-10T04:22:12.290Z","dependency_job_id":null,"html_url":"https://github.com/sysread/SkewHeap-PP","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sysread/SkewHeap-PP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FSkewHeap-PP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FSkewHeap-PP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FSkewHeap-PP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FSkewHeap-PP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysread","download_url":"https://codeload.github.com/sysread/SkewHeap-PP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysread%2FSkewHeap-PP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268355821,"owners_count":24237371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","heap","perl","perl5","prioity-queue","queue","skew","skewheap"],"created_at":"2024-11-14T18:18:23.547Z","updated_at":"2025-08-02T08:39:12.114Z","avatar_url":"https://github.com/sysread.png","language":"Perl","readme":"=pod\n\n=encoding UTF-8\n\n=head1 NAME\n\nSkewHeap::PP - a fast and flexible heap structure\n\n=head1 VERSION\n\nversion 0.02\n\n=head1 SYNOPSIS\n\n  use SkewHeap::PP;\n\n  my $s = skew{ $_[0] \u003c=\u003e $_[1] };\n\n  # Add items one at a time\n  for (@items) {\n    skew_put($s, $_);\n  }\n\n  # Or as a batch\n  skew_put($s, @items);\n\n  # Take individual items\n  my @taken;\n  until (skew_is_empty($s)) {\n    say \"Taking: \" . skew_peek($s);\n\n    push @taken, skew_take($s);\n\n    say \"Left in queue: \" . skew_count($s);\n  }\n\n  # Or take a batch\n  my @take_ten = skew_take($s, 10);\n\n  # Destructively merge two heaps\n  skew_merge($s, $another_skew_heap);\n\n  # Non-destructively merge heaps\n  my $new_heap = skew_merge($a, $b, $c);\n\n=head1 DESCRIPTION\n\nA skew heap is a memory efficient, self-adjusting heap with an amortized\nperformance of O(log n) or better. C\u003cSkewHeap:PP\u003e is implemented in pure perl,\nyet performs comparably to L\u003cSkewHeap\u003e.\n\nThe key feature of a skew heap is the ability to quickly and efficiently merge\ntwo heaps together.\n\n=head2 skew\n\nCreates a new skew heap. Requires a single argument, a code block that knows how\nto prioritize the values to be stored in the heap.\n\n  my $heap = skew{ $_[0] \u003c=\u003e $_[1] };\n\n=head2 skew_count\n\nReturns the number of elements in the heap.\n\n=head2 skew_is_empty\n\nReturns true if the heap is empty.\n\n=head2 skew_peek\n\nReturns the top element in the heap without removing it from the heap.\n\n=head2 skew_take\n\nRemoves and returns the top element from the heap.\n\n  my $item = skew_take($heap);\n\nOptionally, multiple elements may be returned from the heap by passing the\ndesired number of elements, in which case a list is returned, rather than a\nsingle, scalar element. If there are fewer elements available than requested,\nas many as a immediately available are returned.\n\n  # Get 10 elements\n  my @items = skew_take($heap, 10);\n\n=head2 skew_put\n\nAdds one or more items to the heap.\n\n  skew_put($s, 42);\n  skew_put($s, 42, 6, 8);\n\n=head2 skew_merge\n\nMerges any number of heaps into the first argument I\u003cdestructively\u003e. After\nmerging, the first heap passed in will contain all of the items in the heaps\npassed in subsequent arguments. After merging, the subsequent heaps will be\nempty. The comparison function used for ordering is that of the first heap\npassed in. The return value is the first heap into which the other heaps were\nmerged.\n\n  skew_merge($x, $y, $z); # $x contains all elements of $x, $y, and $z;\n                          # $y and $z are now empty.\n\n=head2 skew_merge_safe\n\nNon-destructively merges any number of heaps into a new heap whose comparison\nfunction will be that of the first heap in the list to merge. Returns a new\nheap containing all of the items in each of the other heaps. The other heaps'\ncontents will remain intact.\n\n=head2 skew_explain\n\nPrints out a representation of the internal tree structure for debugging.\n\n=head1 OBJECT INTERFACE\n\nAn object interface is provided that maps directly to the similarly named\nC\u003cskew_*\u003e routines.\n\n=over\n\n=item new - SEE L\u003c/skew\u003e\n\n=item count - SEE L\u003c/skew_count\u003e\n\n=item is_empty - SEE L\u003c/skew_is_empty\u003e\n\n=item peek - SEE L\u003c/skew_peek\u003e\n\n=item take - SEE L\u003c/skew_take\u003e\n\n=item put - SEE L\u003c/skew_put\u003e\n\n=item merge - SEE L\u003c/skew_merge\u003e\n\n=item merge_safe - SEE L\u003c/skew_merge_safe\u003e\n\n=item explain = SEE L\u003c/skew_explain\u003e\n\n=back\n\n=head1 SEE ALSO\n\n=over\n\n=item L\u003cSkewHeap\u003e\n\nWritten in XS and roughly 2x faster.\n\n=item L\u003chttps://en.wikipedia.org/wiki/Skew_heap\u003e\n\n=back\n\n=head1 AUTHOR\n\nJeff Ober \u003csysread@fastmail.fm\u003e\n\n=head1 COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2020 by Jeff Ober.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n\n=cut\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fskewheap-pp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysread%2Fskewheap-pp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysread%2Fskewheap-pp/lists"}