Help for this page

Select Code to Download


  1. or download this
    package FixedSizeQueue;
    use Moose;
    ...
     push @{$this->items}, $item;
     shift @{$this->items} if scalar @{$this->items} > $this->max_size;
    }
    
  2. or download this
    my $q = FixedSizeQueue->new(max_size => 3);
    $q->push(3);
    ...
    $q->push(7);
    $q->push(9);
    print Dumper($q);
    
  3. or download this
    sub BUILDARGS {
      my($this, $max_size)=@_;
    
      return { max_size => $max_size };
    }
    
  4. or download this
    my $q = FixedSizeQueue->new(3);
    $q->push(3);
    ...
    $q->push(7);
    $q->push(9);
    print Dumper($q);