Data-CircularList

 view release on metacpan or  search on metacpan

lib/Data/CircularList.pm  view on Meta::CPAN

    # you have to write sort logic in compare_to method.
    package Person;

    sub new {
        my $class = shift;
        my %args = @_;
        my $self = {
            name => $args{'name'},
            length => length($args{'name'}),
        };
        bless $self => $class;
        $self->length(length($args{'name'}));
        return $self;
    }

    # sort by length of name, and name
    sub compare_to {
        my $self = shift;
        my $cell = shift;

        if ($self->length > $cell->length) {

lib/Data/CircularList.pm  view on Meta::CPAN


constructor. Any arguments don't require.

=cut

sub new {
    my $class = shift;
    my $self = {};
    $self->{'header'} = Data::CircularList::Cell->new("!!Circular List Header!"),
    $self->{'header'}->next($self->{'header'}),
    bless $self => $class;
    return $self;
}

=head2 insert($cell)

insert a cell on the circular linked list.
You can see SYNOPSIS as a example.

=cut

lib/Data/CircularList/Iterator.pm  view on Meta::CPAN

=cut

sub new {
    my ($class, $circular_list, $rotate) = @_;
    my $self = {
        p => $circular_list->header,
        header => $circular_list->header,
        rotate => defined $rotate ? $rotate : undef,
        rotate_count => 0,
    };
    bless $self => $class;
    return $self;
}

=head2 has_next

return boolean value(1 or 0).
If the linkedList has next cell, this method return 1.
If the linkedList has not next cell, this method return 0.

=cut

t/02-etercase.t  view on Meta::CPAN


package Person;

sub new {
    my $class = shift;
    my %args = @_;
    my $self = {
        name => $args{'name'},
        length => length($args{'name'}),
    };
    bless $self => $class;
    $self->length(length($args{'name'}));
    return $self;
}

# sort by name's length
sub compare_to {
    my $self = shift;
    my $cell = shift;

    if ($self->length > $cell->length) {



( run in 0.291 second using v1.01-cache-2.11-cpan-3b35f9de6a3 )