View on
MetaCPAN
Mary Ehlers > Piper-0.05 > Piper::Queue

Download:
Piper-0.05.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

Piper::Queue - Simple FIFO queue used by Piper

SYNOPSIS ^

  use Piper::Queue;

  my $queue = Piper::Queue->new();
  $queue->enqueue(qw(x y));
  $queue->ready;         # 2
  $queue->dequeue;       # 'x'
  $queue->requeue('x');
  $queue->dequeue;       # 'x'

CONSTRUCTOR ^

new

METHODS ^

dequeue($num)

Remove and return at most $num items from the queue. The default $num is 1.

If $num is greater than the number of items remaining in the queue, only the number remaining will be dequeued.

Returns an array of items if wantarray, otherwise returns the last of the dequeued items, which allows singleton dequeues:

    my @results = $queue->dequeue($num);
    my $single  = $queue->dequeue;

enqueue(@items)

Add @items to the queue.

ready

Returns the number of elements in the queue.

requeue(@items)

Inserts @items to the top of the queue in an order such that dequeue(1) would subsequently return $items[0] and so forth.

SEE ALSO ^

Piper::Role::Queue
Piper

VERSION ^

version 0.05

AUTHOR ^

Mary Ehlers <ehlers@cpan.org>

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2017 by Mary Ehlers.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004
syntax highlighting: