Salvador Fandiño García > Array-Shuffle > Array::Shuffle

Download:
Array-Shuffle-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Array::Shuffle - fast shuffling of arrays in-place

SYNOPSIS ^

  use Array::Shuffle qw(shuffle_array);
  shuffle_array(@a);

DESCRIPTION ^

This module provide some functions for shuffling arrays in-place efficiently.

API

shuffle_array @a

Shuffles the given array in-place using the Fisher-Yates algorithm that is O(N).

This function is an order of magnitude faster than the shuffle function from List::Util.

shuffle_huge_array @a

Shuffles the given array in-place using an algorithm that is O(NlogN) but more cache friendly than Fisher-Yates. In some extreme cases, when shuffling huge arrays that do not find in the available RAM it may perform better.

You would like to do some benchmarking to find out which one is better suited for your particular case.

SEE ALSO ^

List::Util.

The following thread on PerlMonks for a discussion on the topic: http://perlmonks.org/?node_id=953607.

COPYRIGHT AND LICENSE ^

Copyright (C) 2012 by Salvador Fandiño (sfandino@yahoo.com)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: