The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

String::Eertree - Build the palindromic tree aka Eertree for a string

VERSION

Version 0.03

SYNOPSIS

Eertrees make it possible to find palindrome substrings of a string in a very fast way.

    use String::Eertree;

    my $tree = 'String::Eertree'->new(string => 'referee');
    my @palindromes = $tree->uniq_palindromes;  # r e f efe refer ere ee

To see how fast it is, check the file examples/rosetta-code.pl. It compares the speed of the Eertree algorithm to a naive generation of all the unique palindromes as found at Rosetta Code. Eertree is almost 40 times faster on a string of length 79.

METHODS

new

  'String::Eertree'->new(string => 'xxx')

The constructor. Use the named argument string to specify the string you want to analyse.

string

  my $string = $tree->string;

The original string the tree was constructed from (see above).

uniq_palindromes

  my @palindromes = $tree->uniq_palindromes;

Returns all distinct palindrome substrings of the string.

palindromes

  my @palindromes = $tree->palindromes;

Returns all the palindrome substrings of the string, each substring can be repeated if it's present at different positions in the string.

AUTHOR

E. Choroba, <choroba at cpan.org>

BUGS

Please report any bugs or feature requests to bug-string-eertree at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=string-eertree. 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 String::Eertree

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks Mohammad S Anwar (MANWAR) for introducing me to the idea.

Thanks shubham2508 for a clean Python implementation.

Thanks Mikhail Rubinchik and Arseny M. Shur for inventing the eertree (arXiv:1506.04862v2 [cs.DS] 17 Aug 2015).

LICENSE AND COPYRIGHT

This software is Copyright (c) 2022-2023 by E. Choroba.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)