Acme-Rautavistic-Sort

 view release on metacpan or  search on metacpan

lib/Acme/Rautavistic/Sort.pm  view on Meta::CPAN

use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS);

@ISA = qw(Exporter);

@EXPORT_OK   = qw(dropsort dropsortx);
%EXPORT_TAGS = (all => [ qw(dropsort dropsortx) ]);

sub dropsort {
        no warnings 'uninitialized';
        my $last;
        map { $_ ge $last ? $last = $_ : () } @_;
}

sub dropsortx(&@)
{
        # magic variables $a and $b
        use vars qw($a $b);
        no strict 'refs';
        no warnings 'uninitialized';
        my $caller = caller;
        local(*{$caller."::a"}) = \my $a;
        local(*{$caller."::b"}) = \my $b;

        my $comparator = shift;
        my $last;
        map {
             $a = $_;
             $b = $last;
             $comparator->() >= 0 ? $last = $_ : ()
            } @_;
}

1; # End of Acme::Rautavistic::Sort

# TODOs / Ideas:
#   Attribute : Rautavistic(dropsort)

t/dropsort.t  view on Meta::CPAN

is_deeply(\@res, [ 1, 11, 2 ], 'explicitely alpha numeric' );
@res = dropsort 1, 11, 2;
is_deeply(\@res, [ 1, 11, 2 ], 'default alpha numeric' );

# -------------- Benchmarks -----------------------

__END__

# use Benchmark qw(:all) ;

# my @bigarray = map { rand } 1..30_000;
# print "Anzahl: ", (scalar dropsort5 @bigarray), "\n";
# timethese(200, {
#                 'dropsort1' => sub { dropsort1 @bigarray },
#                 'dropsort2' => sub { dropsort2 @bigarray },
#                 'dropsort3' => sub { dropsort3 @bigarray },
#                 'dropsort4' => sub { dropsort4 @bigarray },
#                 'dropsort5' => sub { dropsort5 @bigarray },
#                 'dropsortx' => sub { dropsortx @bigarray },
#                });

t/release-pod-coverage.t  view on Meta::CPAN

use Test::Pod::Coverage 1.08;
use Test::More 0.88;

BEGIN {
    if ( $] <= 5.008008 ) {
        plan skip_all => 'These tests require Pod::Coverage::TrustPod, which only works with Perl 5.8.9+';
    }
}
use Pod::Coverage::TrustPod;

my %skip = map { $_ => 1 } qw(  );

my @modules;
for my $module ( all_modules() ) {
    next if $skip{$module};

    push @modules, $module;
}

plan skip_all => 'All the modules we found were excluded from POD coverage test.'
    unless @modules;



( run in 1.021 second using v1.01-cache-2.11-cpan-49f99fa48dc )