Skip to main content

No project description provided

Project description

JoelData

Simple data types I use in my projects.

pip3 install joeldata

Documentation

Stack

FIFO (like a stack of cups)

from joeldata import Stack
my_stack=Stack()
  • push(item) - adds new item
  • pop() -> item - removes item
  • peek() -> item - see top item without removing
  • is_empty() -> bool

Queue

LIFO (like a line at a store)

from joeldata import Queue
my_q=Queue()
  • enqueue(item) - add new item
  • dequeue() -> item - remove an item
  • peek() -> item - see the item that next to be dequeued
  • is_empty() -> bool

BST (aliased to Binary Search Tree)

Stores a list of numbers in a tree where each node can have up to two chiuldren. The left node is always less than the parent node and the right node is always greater than the parent node.

from joeldata import BST
my_bst=BST()
  • add(item) - adds an item to the BST
  • search(value) -> bool - sees if a value is in the BST
  • inorder() -> item[] - returns the items as an array in order
  • remove(item) - removes an item from the BST

HashTable

Implementation of the object in JavaScript, java.util.HashMap in Java, and dictionary in Python.

from joeldata import HashTable
my_ht=HashTable()
  • get(key) -> value - returns the HashMap's value of the key
  • set(key, value) - sets the HashMap to your value at the key
  • clear() - removes all the key-value pairs, emptying the HashMap.
  • remove(key) -> value - removes the key-value pairs at the specified key. Returns the removed value.
  • size() -> int - returns the number of key-value pairs.
  • is_empty() -> bool - returns whether or not the HashMap has no key-value pairs.
  • has(key) -> bool - returns whether or not the HashMap has a key-value pair of the specified key.
  • keys() -> any[] - returns all the keys of the HashMap in an array.
  • values() -> any[] - returns all the values of the HashMap in an array.
  • inspect() -> str - returns the raw self.data for development purposes

Example

>>> from joeldata import HashTable
>>> ht=HashTable()
>>> ht.set('hi', 'world')
>>> ht.get('hi')
'world'
>>> ht.set('things', ['joel', 'bowl'])
>>> print(ht)
HashTable {
	things: ['joel', 'bowl'],
	hi: world
}
>>> ht.has('hi')
True
>>> ht.size()
2
>>> ht.keys()
['things', 'hi']
>>> ht.values()
[['joel', 'bowl'], 'world']
>>> ht.remove('things')
['joel', 'bowl']
>>> print(ht)
HashTable {
	hi: world
}
>>> ht.clear()
>>> print(ht)
{}

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

joeldata-1.0.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

joeldata-1.0.5-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file joeldata-1.0.5.tar.gz.

File metadata

  • Download URL: joeldata-1.0.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for joeldata-1.0.5.tar.gz
Algorithm Hash digest
SHA256 5dc585c477e9eccf8e5db8491364ed03e2381f87b3f0fcd8b2144ddf9eb86662
MD5 a1c89db9bf50129d1bd0f8d42292cf00
BLAKE2b-256 a1dd346bc12d6ed20a18f295b54ee15221b5dad47ddbac8ef1bec9629674e2d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: joeldata-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for joeldata-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1dae13b2ac8ab0dc1bd090d6e27d8ebb8b6095dd57e53c644d826446ddd0c5
MD5 d588f019b2d8429dbc2cec820d189a4d
BLAKE2b-256 ee8409b32ac500db6e86109f68185b553a285a47323a9a262c6c38ee0130694f

See more details on using hashes here.

Supported by

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