List::Util::WeightedRoundRobin - Creates a list based on weighted input


List-Util-WeightedRoundRobin documentation  | view source Contained in the List-Util-WeightedRoundRobin distribution.

Index


NAME

Top

List::Util::WeightedRoundRobin - Creates a list based on weighted input

SYNOPSIS

Top

  my $list = [
    {
        name    => 'jingle',
        weight  => 6,
    },
    {
        name    => 'bells',
        weight  => 2,
    },
  ];

  my $WeightedList = List::Util::WeightedRoundRobin->new();
  my $weighted_list = $WeightedList->create_weighted_list( $list );

DESCRIPTION

Top

List::Util::WeightedRoundRobin is a utility for creating a weighted list based on the input and associated weights.

METHOD

Top

new

Constructs a new List::Util::WeightedRoundRobin and returns it. Takes no arguments.

create_weighted_list

Takes an array reference as an argument. The array reference must contain hash entries which have a 'name' and 'weight' key.

If the sources are valid and a weighted list has been created, the method will return a weighted list. In the case of an error, the returned list will be empty.

AUTHOR

Top

Alistair Francis, http://search.cpan.org/~friffin/

COPYRIGHT AND LICENSE

Top


List-Util-WeightedRoundRobin documentation  | view source Contained in the List-Util-WeightedRoundRobin distribution.