Queues and trees.
Project description
Datastructs
Datastructs is a small module containing trees and queues.
Queues
Queues are very simple. To create one, you can just use queue() with an iterable inside, or nothing to create an empty queue. They have two functions: enqueue(value), which inserts a given value to the beginning of the queue, and dequeue(), which removes the last element and returns it.
Trees and nodes
Trees and nodes are a bit more complicated. To create a tree, you can use tree(), with a value for the base node, or nothing to have the value be None. Nodes have a few functions. First there is set(value) which sets the value of the node, set_parent(node) which changes its parent node, add_child(value) which adds a child with that values to that nodes "children" list, and remove_child(node), which removes a child. The tree has an update() function, where you can optionally give it a new base node, and you never truly need to call it, as all of the node functions call it themselves. Nodes are indexed in a specific way in a tree's "nodes" list. It is a nested list, where each index of the list contains the nodes in that layer. Layer 0 is the base node, layer 1 is its children, and so on.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datastructs-sparkles58-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a13ec4d60542dc591eeca645a505817f7e7bf6f53358ff72a360cc20b72c7994 |
|
MD5 | 0df2c37128b3caf042d6df790b49e7a5 |
|
BLAKE2b-256 | 1dbe54ccc80179bfd06c5265bcd9b60ba40f5b82352ded20614c7573e1ecef13 |
Hashes for datastructs_sparkles58-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e646e68d968179a1276da0e444410cb4b5ff3d612f090385268cafcf640ec327 |
|
MD5 | 46357b8c4cdd350e23fa48fd586c4786 |
|
BLAKE2b-256 | 217d815e3ce57c981b95f04f5fa6fb280092550d0721fac3711954184cfb2c9b |