Skip to main content

AnderssonTree Package

Abstract

This package provides Andersson Tree implementation written in pure Python.

Sources of Algorithms

http://en.wikipedia.org/wiki/Andersson_tree http://user.it.uu.se/~arnea/abs/simp.html http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_andersson.aspx

Some concepts are inspired by bintrees package at http://bitbucket.org/mozman/bintrees, although this implementation does not support dict, heap, set compatibility.

Constructor

  • AnderssonTree() -> new empty tree;

  • AnderssonTree(mapping) -> new tree initialized from a mapping (requires only an items() method)

  • AnderssonTree(seq) -> new tree initialized from seq [(k1, v1), (k2, v2), … (kn, vn)]

Methods

  • __contains__(k) -> True if T has a key k, else False

  • __delitem__(y) <==> del T[y]

  • __getitem__(y) <==> T[y]

  • __iter__() <==> iter(T) <==> keys()

  • __len__() <==> len(T)

  • __repr__() <==> repr(T)

  • __reversed__() <==> reversed(T), reversed keys

  • __setitem__(k, v) <==> T[k] = v

  • __copy__() <==> copy()

  • clear() -> None, remove all items from T

  • copy() -> a shallow copy of T, tree structure, i.e. key insertion order is preserved

  • dump([order]) -> None, dumps tree according to order

  • get(k) -> T[k] if k in T, else None

  • insert(k, v) -> None, insert node with key k and value v, replace value if key exists

  • is_empty() -> True if len(T) == 0

  • iter_items([, reverse]) -> generator for (k, v) items of T

  • keys([reverse]) -> generator for keys of T

  • remove(key) -> None, remove item by key

  • remove_items(keys) -> None, remove items by keys

  • root() -> root node

  • traverse(f, [order]) -> visit all nodes of tree according to order and call f(node) for each node

  • update(E) -> None. Update T from dict/iterable E

  • values([reverse]) -> generator for values of T

Order values

  • ORDER_INFIX_LEFT_RIGHT - infix order, left child first, then right

  • ORDER_INFIX_RIGHT_LEFT - infix order, right child first, then left

  • ORDER_PREFIX_LEFT_RIGHT - prefix order, left child first, then right

  • ORDER_PREFIX_RIGHT_LEFT - prefix order, right child first, then left

  • ORDER_POSTFIX_LEFT_RIGHT - postfix order, left child first, then right

  • ORDER_POSTFIX_RIGHT_LEFT - postfix order, right child first, then left

Installation

from source:

python setup.py install

or from PyPI:

pip install anderssontree

Documentation

this README.rst, code itself, docstrings

anderssontree can be found on github.com at:

https://github.com/darko-poljak/andersontree

Tested With

Python2.7.5, Python3.3.2

Release files for anderssontree 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anderssontree 0.1.0
File Size Uploaded
anderssontree-0.1.0.tar.gz 7.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for anderssontree 0.1.0
File Interpreter ABI Platform
anderssontree-0.1.0-py3.3.egg Legacy Egg format - - Details
anderssontree-0.1.0-py2.7.egg Legacy Egg format - - Details

Total release size: 32.1 kB

Release files / anderssontree-0.1.0.tar.gz

Download URL anderssontree-0.1.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
852f17805d544fffa48ed7736c474ab1f8bf92b6bb800d6625755261986002c1
BLAKE2b-256 checksum
How to use checksums
698fd83c26ebeb5c43ae7ce31fb74dd3fa73246e9649df83b7ebd419e4cebfaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / anderssontree-0.1.0-py3.3.egg

Download URL anderssontree-0.1.0-py3.3.egg
Size 12.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
c72541b82823743c1bbbef6712cc7899eeb00c2de6a462b08a9c638e8ff8cb1f
BLAKE2b-256 checksum
How to use checksums
64041e8c5a6637e6d0752f82d543c57cdfb008a10058c96d12d8321cfed02d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / anderssontree-0.1.0-py2.7.egg

Download URL anderssontree-0.1.0-py2.7.egg
Size 12.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
eec88c9dbb684556e862afabbd9865c4d1e2ef64d78d99be4b3cb44d0b37c5ee
BLAKE2b-256 checksum
How to use checksums
d06cbb8df2085248cf0d97fcde83555c76b0cb3e32a0c1cab75696ceb9645487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page