A MutableSet that remembers its order, so that every entry has an index.
Project description
An OrderedSet is a custom MutableSet that remembers its order, so that every entry has an index that can be looked up.
Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger, and released under the MIT license:
Rob Speer’s changes are as follows:
changed the content from a doubly-linked list to a regular Python list. Seriously, who wants O(1) deletes but O(N) lookups by index?
add() returns the index of the added item
index() just returns the index of an item
added a __getstate__ and __setstate__ so it can be pickled
added __getitem__
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
File details
Details for the file ordered-set-1.2.tar.gz
.
File metadata
- Download URL: ordered-set-1.2.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6abbd4b5180cdb0251321e600bd7f37ed289e2bcea817e0205df0477ee98193c |
|
MD5 | 97316ebb173d84e27da11d2404ae8a67 |
|
BLAKE2b-256 | 1bcf44f194a4b743552aaebb250cfcb8823693f7870303a4177f7eaa4c28e19f |