Set that maintains insertion order
Project description
ordered-hash-set is data structure that stores immutable unique elements. Unlike built-in set in python, it also keeps the insertion order.
Installation
Install via pip:
pip install ordered-hash-set
Or install from source:
python3 setup.py install
Basic Usage
from ordered_hash_set import OrderedSet
s = OrderedSet()
s.add("London")
s.add("Tokyo")
# you can add multiple entries at once, like this:
s.update("Paris", "Istanbul")
s.add("London")
s.remove("Tokyo")
print(s) # prints: OrderedSet(London, Paris, Istanbul)
# Thanks to the hashing. Time complexity of checking
# if an element present in a collection is O(1).
# Which is faster than regular list: O(n).
if "Paris" in s:
print("Paris is in the set.")
# It is also possible, but not recommended due to inefficiency,
# to get the item by index:
assert s[2] == "Istanbul"
API Documentation
Please see API Reference Page
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
File details
Details for the file ordered-hash-set-0.1.3.tar.gz
.
File metadata
- Download URL: ordered-hash-set-0.1.3.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be403fc485eb6ec5314855efd13ab593c46b87746ff6cd14a91c010721af54dc |
|
MD5 | 9c6b1beda68a0a8aaa0ce6cd61b7e917 |
|
BLAKE2b-256 | 5af881b896cb5d2d2a3fdba4dbf5f061c34f92f9cf64e438d27d759b5befd938 |
File details
Details for the file ordered_hash_set-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: ordered_hash_set-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ecea1a1f39cf10cb0cf9ec0064a91a7e85de8d9d441cc2d3d76ec5b1d181c3e |
|
MD5 | d30627368d3148687501b1a0a048fd02 |
|
BLAKE2b-256 | fc3c43823dd1958e8f3c61a0ab2236dde61a0573dd735785908ac706574dd1f5 |