Acme-Selection-RarestFirst
view release on metacpan or search on metacpan
CODE_OF_CONDUCT.md view on Meta::CPAN
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
```perl
use Acme::Selection::RarestFirst;
my $selector = Acme::Selection::RarestFirst->new( size => 100 );
# Update availability based on what peers have
$selector->update( $peer_bitfield, 1 ); # peer joined
$selector->update( $peer_bitfield, -1); # peer left
# Pick the next best item to request
my $idx = $selector->pick( $my_bitfield );
```
# DESCRIPTION
`Acme::Selection::RarestFirst` implements the classic "rarest-first" algorithm used in distributed systems to ensure
high data availability. It prioritizes items that have the lowest count in the global set (the "swarm").
# METHODS
lib/Acme/Selection/RarestFirst.pod view on Meta::CPAN
=head1 SYNOPSIS
use Acme::Selection::RarestFirst;
my $selector = Acme::Selection::RarestFirst->new( size => 100 );
# Update availability based on what peers have
$selector->update( $peer_bitfield, 1 ); # peer joined
$selector->update( $peer_bitfield, -1); # peer left
# Pick the next best item to request
my $idx = $selector->pick( $my_bitfield );
=head1 DESCRIPTION
C<Acme::Selection::RarestFirst> implements the classic "rarest-first" algorithm used in distributed systems to ensure
high data availability. It prioritizes items that have the lowest count in the global set (the "swarm").
=head1 METHODS
=head2 C<update( $bitfield, $delta )>
( run in 0.759 second using v1.01-cache-2.11-cpan-39bf76dae61 )