Algorithm-Bucketizer

 view release on metacpan or  search on metacpan

Bucketizer.pm  view on Meta::CPAN

           
                     # Internal stuff

                   # index (0-..) of bucket we're currently 
                   # inserting items into
                 cur_bucket_idx  => 0,

                 buckets         => [],
               };

    bless $self, $class;
}

##################################################
sub add_item {
##################################################
    my($self, $item, $size) = @_;

      # in 'simple' mode, we continue with the bucket we
      # inserted the last item into
    my $first = $self->{cur_bucket_idx};

Bucketizer.pm  view on Meta::CPAN


    my $self = { size      => 0,
                 items     => [],
                 sizes     => [],
                 maxsize   => undef,
                 maxitems  => undef,
                 idx       => 0,
                 @options,
               };

    bless $self, $class;
}

##################################################
sub serial {
##################################################
    my($self) = @_;

    return ($self->{idx} + 1);
}



( run in 1.025 second using v1.01-cache-2.11-cpan-de7293f3b23 )