#
# IPtoLL
#
# Robert Olson
# olson@mcs.anl.gov
# Argonne National Laboratory
# September, 1996
#
# Please keep this heading attached to the file it heads.
#
package CircularList;

#
# Simple list module
#

sub new
{
    my($class, @elts) = @_;
    my($self);
    $self = {
	elements => [@elts],
	next_elt => 0,
	n_elts => int(@elts),
    };
    bless($self, $class);
    return $self;
}

sub next
{
    my($self) = @_;
    my($elt_idx);
    $elt_idx = $self->{next_elt};
    $self->{next_elt} = ($elt_idx + 1) % $self->{n_elts};
    return $self->{elements}->[$elt_idx]
}

1;
