Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/skewheap
A fast, efficient, self-adjusting heap for Perl, implemented in C
https://github.com/sysread/skewheap
c data-structures heap perl skew-heap xs
Last synced: 6 days ago
JSON representation
A fast, efficient, self-adjusting heap for Perl, implemented in C
- Host: GitHub
- URL: https://github.com/sysread/skewheap
- Owner: sysread
- Created: 2018-03-20T19:46:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-26T17:27:12.000Z (about 6 years ago)
- Last Synced: 2023-08-20T23:10:03.264Z (over 1 year ago)
- Topics: c, data-structures, heap, perl, skew-heap, xs
- Language: XS
- Size: 72.3 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
=head1 NAME
SkewHeap - A fast and flexible heap structure
=head1 SYNOPSIS
use SkewHeap;
my $heap = skewheap{ $a <=> $b };
$heap->put(42);
$heap->put(35);
$heap->put(200, 62);$heap->top; # 35
$heap->size; # 4$heap->take; # 35
$heap->take; # 42
$heap->take; # 62
$heap->take; # 200my $merged_heap = $heap->merge($other_skewheap);
=head1 DESCRIPTION
A skew heap is a memory efficient, self-adjusting heap (or priority queue) with
an amortized performance of O(log n) (or better). C is implemented in
C/C.The key feature of a skew heap is the ability to quickly and efficiently merge
two heaps together.=head1 METHODS
=head2 skewheap
Creates a new C which will be sorted in ascending order using the
comparison subroutine passed in. This sub has the same semantics as Perl's
C, returning -1 if C<$a E $b>, 1 if C<$a E $b>, or 0 if
C<$a == $b>.=head2 size
Returns the number of elements in the heap.
=head2 top
Returns the next element which would be returned by L without removing
it from the heap.=head2 put
Inserts one or more new elements into the heap.
=head2 take
Removes and returns the next element from the heap.
=head2 merge
Non-destructively merges two heaps into a new heap. Returns the new heap.
=head1 AUTHOR
Jeff Ober
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Jeff Ober. This is free software; you
can redistribute it and/or modify it under the same terms as the Perl 5
programming language system itself.