Skip to main content

A thread safe implementation of a Trie.

Project description

Poe[Trie]s

Description

Poetries provides a thread-safe implementation of a Trie. While not limited, but the most common use case of a Trie is in implementing auto-completion. The collection type exposes APIs to perform the following operationsadd, find and get_all_words_with_prefix.

Dependencies

Python 3

Installation

pip install --upgrade poetries

Usage

from poetries.trie import Trie


trie = Trie()
trie.add('foobar')              # Adds 'foobar' to the trie
trie.find('foo')                # Returns False since the word is not present.
trie.add('bar')                 # Adds 'bar' to the trie
trie.find('bar')                # Returns True
trie.add('foob')                # Adds 'foob' to the trie
trie.add('foof')                # Adds 'foof' to the trie
arr = list(trie.prefix('foo'))  # Returns the list of words beginning with foo in a list form, ['foobar', 'foo', 'foob', 'foof']

License

MIT

Changelog

Project details


Release history Release notifications

This version

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for poetries, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size poetries-1.0.0-py3-none-any.whl (2.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size poetries-1.0.0.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page