Travis Kent Beste > RingBuffer-0.04 > RingBuffer



Annotate this POD

View/Report Bugs
Module Version: 5   Source  


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


  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

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

  # clear out the ring, also zeros out the data


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:

        Initialize the ring with your object passed to the
the 'Buffer=><obj>' argument.
        Clear the ring of all objects.
        Add an object to the buffer of the ring.
        Remove an object from the ring and return it.
        Return the size of the ring, takes into account the wrapping
around of the ring.
        Add a piece of data to the front of the ring
        Change a piece of data in the ring at the current head location.
        Take a look at the item on the ring to be returned,
but do not remove it from the ring.
        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.


None by default.


None that I know of right now.



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


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

Travis Kent Beste, <>


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: