orderedset: An ordered set#

orderedset: An ordered set#

Inspiration and code expanded from Raymond Hettinger’s indexable weak ordered set and Stephan Schroevers’ does python have an ordered set stackoverflow.com postings.

class OrderedSet(values=())#

Bases: MutableSet

Ordered set.

Supports all of the operations that can happen on a set.

add(value)#

Experimental API . Add an element.

clear()#

Experimental API . This is slow (creates N new iterators!) but effective.

discard(value)#

Experimental API . Remove an element. Do not raise an exception if absent.

issubset(other)#

Experimental API . Return self<=value.

issuperset(other)#

Experimental API . Return self>=value.

union(other)#

Experimental API . Return self|value.

class OrderedWeakrefSet(values=())#

Bases: WeakSet

Ordered set of weak references