py_treap module¶
Provides a treap module - specifically, the class that describes the overall treap, not the nodes.
A treap is a datastructure that’s kind of half way between a heap and a binary search tree
- py_treap.center(string, field_use_width, field_avail_width)[source]¶
Center a string within a given field width
- class py_treap.treap[source]¶
Bases:
object
The treap class - or rather, the non-node, treap-proper
- detailed_inorder_traversal(visit)[source]¶
Perform an inorder traversal of the treap, passing a little more detail to the visit function at each step
- find(key)¶
Look up a node in the treap: return the value
- insert(key, value, priority=None)¶
Insert a node in the treap
- items()¶
A macro for iterators - produces keys, values and items from almost the same code
- iterator()¶
A macro for iterators - produces keys, values and items from almost the same code
- iteritems()[source]¶
A macro for iterators - produces keys, values and items from almost the same code
- iterkeys()[source]¶
A macro for iterators - produces keys, values and items from almost the same code
- itervalues()[source]¶
A macro for iterators - produces keys, values and items from almost the same code
- keys()¶
A macro for iterators - produces keys, values and items from almost the same code
- remove(key)¶
Remove a node from the treap
- class state_class(todo, node)[source]¶
Bases:
object
A state class, used for iterating over the nodes in a treap nonrecursively
- to_dot(file_=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'>)[source]¶
Output this tree as a dot file
- values()¶
A macro for iterators - produces keys, values and items from almost the same code
- class py_treap.treap_node[source]¶
Bases:
object
Hold a single node of a treap
- detailed_inorder_traversal(visit, depth=0, from_left=0)[source]¶
Do an inorder traversal - with lots of parameters
- key¶
- left¶
- priority¶
- right¶
- to_dot(initial=True, file_=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'>, visited=None)[source]¶
Generate a dot file describing this tree
- value¶