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-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4bdbf3f7b8e48abd99166eea76d512dcf4ed84022f1a79dce16da8522d21f92 |
|
MD5 | 346171c27a51d2bef194b2e11e4c1010 |
|
BLAKE2b-256 | f23150966e7195ba1e80a772f6fa9db48f783005344e39b491443a67cbfb40e2 |
Hashes for datastructs_sparkles58-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f50d84a13cccd2d8c9b5d50dc0f12e1828c4e5e91479d9916d93f527d23575a |
|
MD5 | fe420f94bed36ea563291aec10e26730 |
|
BLAKE2b-256 | d0f30bb6b16488dbabc96de200766a39cab04bbade6fbd43eb423329556f28c6 |