Skip to main content

Queues and trees.

Project description

Datastructs

Datastructs is a small module containing trees and queues.

NOTE: all objects are under datastructs.datastructs

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datastructs-sparkles58-1.0.5.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datastructs_sparkles58-1.0.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file datastructs-sparkles58-1.0.5.tar.gz.

File metadata

  • Download URL: datastructs-sparkles58-1.0.5.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for datastructs-sparkles58-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c5b7751ef63715762e6531d8ac672a7c64fa1eca51f977c61b923b1a60ba5ee9
MD5 4c4ca5e0bfb413012ffbd1ed16d1bd7c
BLAKE2b-256 6a04e6610308fdfdac4d6b431b5912a88139269842f6388986983d4dc58a0ed1

See more details on using hashes here.

File details

Details for the file datastructs_sparkles58-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: datastructs_sparkles58-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for datastructs_sparkles58-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 753309b5819c332c7ed08e7934b7548229b269bac12d00e0e38c8dab82d0a96b
MD5 5616dc8f717436aee7664b0b33facd01
BLAKE2b-256 fdad9a44d6eb73fd6af30fd474c6d25e0e7ad28684a2e45a51a6b25733858d85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page