Algorithm::TernarySearchTree

the algorithm which blends trie and binary search tree

NAME

Algorithm::TernarySearchTree - the algorithm which blends trie and binary search tree

SYNOPSIS

use Algorithm::TernarySearchTree;

my $tst = Algorithm::TernarySearchTree.new();

$tst.insert("Perl6 is fun");
$tst.insert("Perl5 is fun");

my $false-flag = $tst.contains("Kotlin is fun"); # False
my $true-flag = $tst.contains("Perl6 is fun"); # True

my $matched = $tst.partial-match("Perl. is fun"); # set("Perl5 is fun","Perl6 is fun")
my $not-matched = $tst.partial-match("...lin is fun"); # set()

DESCRIPTION

Algorithm::TernarySearchTree is a implementation of the ternary search tree. Ternary search tree is the algorithm which blends trie and binary search tree.

CONSTRUCTOR

new

my $tst = Algorithm::TernarySearchTree.new();

METHODS

insert(Str $key)

$tst.insert($key);

Inserts the key to the tree.

contains(Str $key) returns Bool:D

my $flag = $tst.contains($key);

Returns whether given key exists in the tree.

partial-match(Str $fuzzy-key) returns Set:D

my Set $matched = $tst.partial-match($fuzzy-key);

Searches partially matched keys in the tree. If you want to match any character except record separator(hex: 0x1e), you can use dot symbol. For example, the query "Perl." matches "Perla", "Perl5", "Perl6", and so on.

METHODS NOT YET IMPLEMENTED

near-search, traverse, and so on.

AUTHOR

titsuki [email protected]

COPYRIGHT AND LICENSE

Copyright 2016 titsuki

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

This algorithm is from Bentley, Jon L., and Robert Sedgewick. "Fast algorithms for sorting and searching strings." SODA. Vol. 97. 1997.

Algorithm::TernarySearchTree v0.0.5

the algorithm which blends trie and binary search tree

Authors

  • Itsuki Toyota

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Algorithm::TernarySearchTree
  • Algorithm::TernarySearchTree::Node

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.