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()¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- iterator()¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- iteritems()[source]¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- iterkeys()[source]¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- itervalues()[source]¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- keys()¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- 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='utf-8'>)[source]¶
Output this tree as a dot file.
- values()¶
Produce keys, values and items from almost the same code - a macro since these are very similar.
- 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='utf-8'>, visited=None)[source]¶
Generate a dot file describing this tree.
- value¶