Travis Kent Beste > RingBuffer-0.04 > RingBuffer

Download:
RingBuffer-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 5   Source  

NAME ^

RingBuffer - Perl extension for creating a ring buffer of any size with any object as the ring data.

SYNOPSIS ^

  use RingBuffer;
  my $buffer            = [];
  my $ringsize          = 256;
  my $overwrite         = 0;
  my $printextendedinfo = 0;
  my $r = new RingBuffer(
    Buffer            => $buffer,
    RingSize          => $ringsize,
    Overwrite         => $overwrite,
                PrintExtendedInfo => $printextendedinfo,
        );

  # initialize the ring, in this case with an array
  $r->ring_init(); # will create 256 ring buffer of array objects

  # remove an object from the ring
  my $obj = $r->ring_remove();

  # add an object to the front of the ring
  # this is usually used for putting items back on the ring
  $r->ring_add_to_front($obj);

  # peek at the next item on the ring
  my $obj = $r->ring_peek();

  # clear out the ring, also zeros out the data
  $r->ring_clear();

DESCRIPTION ^

This software create a ring buffer of <n> length. You can store any type of object inside the buffer that you create. Description of the functions are listed below:

$r->ring_init();
        Initialize the ring with your object passed to the
the 'Buffer=><obj>' argument.
$r->ring_clear();
        Clear the ring of all objects.
$r->ring_add();
        Add an object to the buffer of the ring.
$r->ring_remove();
        Remove an object from the ring and return it.
$r->ring_size();
        Return the size of the ring, takes into account the wrapping
around of the ring.
$r->ring_add_to_front();
        Add a piece of data to the front of the ring
$r->ring_change();
        Change a piece of data in the ring at the current head location.
$r->ring_peek();
        Take a look at the item on the ring to be returned,
but do not remove it from the ring.
$r->ring_print();
        Print the contents of the ring.  Could be a huge printout
if you make the ring size large.  Also you can set the variable 
'PrintExtendedInfo' and get the head and tail on a seperate line.

EXPORT

None by default.

BUGS ^

None that I know of right now.

SEE ALSO ^

perl(1).

I also have a website where you can find the latest versions of this software:

http://www.travisbeste.com/software/perl/RingBuffer

AUTHOR ^

Please e-mail me with problems, bug fixes, comments and complaints.

Travis Kent Beste, <travis@tencorners.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2008 by Travis Kent Beste

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: