Skip to main content

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:

http://code.activestate.com/recipes/576694-orderedset/

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__

Tested on Python 2.6, 2.7, 3.3, 3.4, PyPy, and PyPy3.

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

ordered-set-1.3.1.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file ordered-set-1.3.1.tar.gz.

File metadata

  • Download URL: ordered-set-1.3.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ordered-set-1.3.1.tar.gz
Algorithm Hash digest
SHA256 bf3ae1ebf12e6fec255cf8bf7e40e3c78bc0fc3d87dcb5a1d71765d504f7918b
MD5 6b00a116f22bd83cb8b9962434139427
BLAKE2b-256 fda022aafdc1c89a23a42c2144158b8ad92cee553770808fae72e0618936a6b7

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