patricia-tree /

Filename Size Date modified Message
src
test
34.3 KB
965 B
324 B

Building the C extension

Go to patricia-tree/ and launch:

python setup.py build

It will generate a 'build/' directory. Then you should 'cd' to 'lib.OS-version/' directory and run a Python interpreter. Here you can use the patricia-tree library.

Using the ternarytree module

Here a simple example for you.

>>> import ternarytree
>>> t = ternarytree.TernarySearchTree()
>>> t.add('hello')
>>> t.contains('hello')
True
>>> t.contains('hell')
False
>>> t.add('hell')
>>> t.contains('hell')
True
>>> t.contains('hello')
True
>>> t.add('hey')
>>> t.add('hexadecimal')
>>> t.add('hex')
>>> t.prefix_search('he')
[u'hello', u'hex', u'hexadecimal', u'hey']
>>> t.prefix_search('hex')
[u'hex', u'hexadecimal']

Running the tests

If you want to run the tests, just run this in patricia-tree/:

python setup.py nosetests

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.