Lukas Mai > Data-PrioQ-SkewBinomial-0.03 > Data::PrioQ::SkewBinomial
Module Version: 0.03

# NAME

Data::PrioQ::SkewBinomial - A functional priority queue based on skew binomial trees

# SYNOPSIS

```    use aliased 'Data::PrioQ::SkewBinomial' => 'PQ';

my \$pq = PQ->empty;
\$pq = \$pq->insert(1, "foo")->insert(3, "baz")->insert(2, "bar");
until (\$pq->is_empty) {
(\$pq, my (\$priority, \$data)) = \$pq->shift_min;
print "\$priority: \$data\n";
}```

# DESCRIPTION

This module provides a purely functional priority queue. "Purely functional" means no method ever modifies a queue; instead they all return a new modified object. There is no real constructor either because there's no need for one: if the empty queue is never modified, you can just reuse it.

The following methods are available:

## Data::PrioQ::SkewBinomial->empty

O(1). Returns the empty queue.

## \$pq->is_empty

O(1). Tests whether a priority queue is empty. Returns a boolean value.

## \$pq->insert(\$priority, \$item)

O(1). Returns a new queue containing `\$item` inserted into `\$pq` with a priority level of `\$priority`. `\$priority` must be a number.

## \$pq->merge(\$pq2)

O(1). Returns a new queue containing all elements of `\$pq` and `\$pq2`.

## \$pq->peek_min

O(1). Finds the item with the lowest priority value in `\$pq`. Returns `(\$priority, \$item)` in list context and `\$item` in scalar context. If `\$pq` is empty, returns the empty list/undef.

## \$pq->shift_min

O(log n). Finds and removes the item with the lowest priority value in `\$pq`. Returns `(\$pq_, \$priority, \$item)` in list context and `\$pq_` in scalar context, where `\$pq_` is a priority queue containing the remaining elements. If `\$pq` is empty, returns `(\$pq, undef, undef)`/`\$pq` in list/scalar context, respectively.

# AUTHOR

Lukas Mai, `<l.mai at web.de>`

# BUGS

Please report any bugs or feature requests to `bug-data-prioq-skewbinomial at rt.cpan.org`, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-PrioQ-SkewBinomial. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

# SUPPORT

You can find documentation for this module with the perldoc command.

`    perldoc Data::PrioQ::SkewBinomial`

You can also look for information at:

# ACKNOWLEDGEMENTS

The code in this module is based on: Chris Okasaki, Purely Functional Data Structures.