Metadata-Version: 2.3
Name: affix-tree
Version: 0.1.0
Summary: A trie-like data structure that allows storing and searching data based on the longest matching prefix or suffix of a given string.
Home-page: https://github.com/ean-db/affix-tree
License: MIT
Keywords: trie,suffix tree,prefix tree
Author: EAN-DB
Author-email: support@ean-db.com
Requires-Python: >=3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Repository, https://github.com/ean-db/affix-tree
Description-Content-Type: text/markdown

# affix-tree

A trie-like data structure that allows storing and searching data based on the longest matching
prefix or suffix of a given string.

## Installation

```commandline
pip install affix-tree
```

## Usage

### As a prefix tree

```pycon
>>> from affix_tree import AffixTree

>>> prefix_tree: AffixTree[int] = AffixTree()
>>> prefix_tree.add('prefix', 1)
>>> prefix_tree.add('prefix-2', 2)

>>> prefix_tree.find('prefix-2-test')

2
```

### As a suffix tree

```pycon
>>> from affix_tree import AffixTree

>>> prefix_tree: AffixTree[int] = AffixTree(is_suffix_tree=True)
>>> prefix_tree.add('suffix', 1)
>>> prefix_tree.add('2-suffix', 2)

>>> prefix_tree.find('test-2-suffix')

2
```

