NAME

Bijection::XS - Bijection of an integer faster

VERSION

Version 0.02

SYNOPSIS

Perhaps a little code snippet.

use Bijection::XS qw/biject inverse/;

my $int = 1;
my $string = biject($int);
inverse($string) == $int;

....

use Bijection::XS qw/all/;

my $offset = 100000000;
bijection_set($offset, qw/b c d f g h j k l m n p q r s t v w x y z B C D F G H J K L M N P Q R S T V W X Y Z 0 1 2 3 4 5 6 7 8 9/);

my $int = 2;
my $string = biject($int);
inverse($string) == $int;

EXPORT

biject

Takes an integer and returns a bijected string.

inverse

Takes an bijected string and returns an integer.

bijection_set

Set the bijective pair "set", this function expects a list of alphanumeric characters.

The following is set by default:

bijection_set(qw/b c d f g h j k l m n p q r s t v w x y z B C D F G H J K L M N P Q R S T V W X Y Z 0 1 2 3 4 5 6 7 8 9/);

offset_set

Offset the bijection by setting an integer value here. This value is used to sum during bijection and substract during inversion.

BENCHMARK

use Benchmark qw(:all);
use lib '.';
use Bijection;
use Bijection::XS;

timethese(10000000, {
	'Bijection' => sub {
		my $int = 10000;
		Bijection::inverse(Bijection::biject($int));
	},
	'XS' => sub {
		my $int = 10000;
		Bijection::XS::inverse(Bijection::XS::biject($int));
	}
});


Benchmark: timing 10000000 iterations of Bijection, XS...
 Bijection:  8 wallclock secs ( 8.74 usr +  0.05 sys =  8.79 CPU) @ 1137656.43/s (n=10000000)
	XS:  2 wallclock secs ( 2.48 usr +  0.01 sys =  2.49 CPU) @ 4016064.26/s (n=10000000)

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-bijection-xs at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bijection-XS. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Bijection::XS

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)