The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Queue - Order/Unordered stack

SYNOPSIS

  use Data::Queue;

  my $stack=new Data::Queue;

  my $id=$stack->add($job);

  while($stack->has_next) {
    my ($id,$job)=$stack->get_next;
  }

DESCRIPTION

Stack, with the ablity to add and remove elements by id on the fly. Elements go in and out of the stack in the id order.

OO Methods

  • my @ids=$stack->add(@list)

    Adds a list of objects onto the stack

    Arguments:

      @ids:  List of ids relative to @list
      @list: List of elements to put on the stack
  • my ($id,$value)=$stack->get_next

    Returns the next id=>value pair from the set.

  • if($stack->has_next) { ... }

    Returns a Data::Result object, when true, it is safe to call $stack->get_next

  • if($self->has_id($id)) { ... }

    Returns a Data::Result object:

      When true:  it contains the object from the stack
      When false: it contains an error message
  • my $id=$stack->add_by_id($id=>$obj);

    Adds the element pair to the stack, with a given id, if the id existed the old element is removed.

  • $stack->remove($id)

    Removes the $id from the stack

  • $self->rebuild_stack

    Internal method for rebuilding the internal stack as needed.

  • my $total=$stack->total

    Returns the total number of elements on the stack

AUTHOR

Mike Shipper Mike Shipper <AKALINUX@CPAN.ORG>