Algorithm-Bucketizer
view release on metacpan or search on metacpan
Bucketizer.pm view on Meta::CPAN
=head2 Algorithms
Currently, C<Algorithm::Bucketizer> comes with two algorithms, C<simple> and
C<retry>.
In C<simple> mode, the algorithm will just try to fit in your items
in the order in which they're arriving. If an item fits into the current bucket,
it's being dropped in, if not, the algorithm moves on to the next bucket. It
never goes back to previous buckets, although a new item might as well
fit in there. This mode might be useful if preserving the original order
of items is required. To query/manipulate the bucket the Bucketizer
will try to fit in the next item, use C<current_bucket_index()> explained
below.
In C<retry> mode, the algorithm will try each existing bucket first,
before opening
a new one. If you have many items of various sizes, C<retry> allows you to fit
them into less buckets than in C<simple> mode.
The C<new()> method chooses the algorithm:
Algorithms
Currently, "Algorithm::Bucketizer" comes with two algorithms, "simple"
and "retry".
In "simple" mode, the algorithm will just try to fit in your items in
the order in which they're arriving. If an item fits into the current
bucket, it's being dropped in, if not, the algorithm moves on to the
next bucket. It never goes back to previous buckets, although a new item
might as well fit in there. This mode might be useful if preserving the
original order of items is required. To query/manipulate the bucket the
Bucketizer will try to fit in the next item, use
"current_bucket_index()" explained below.
In "retry" mode, the algorithm will try each existing bucket first,
before opening a new one. If you have many items of various sizes,
"retry" allows you to fit them into less buckets than in "simple" mode.
The "new()" method chooses the algorithm:
my $dumb = Algorithm::Bucketizer->new( algorithm => "simple" );
( run in 0.225 second using v1.01-cache-2.11-cpan-1c8d708658b )