trw.simple_layers.ordered_set

Module Contents

Classes

OrderedSet

Ordered set

class trw.simple_layers.ordered_set.OrderedSet(iterable=None)

Bases: collections.MutableSet

Ordered set

Implementation based on a doubly linked link and an internal dictionary. This design gives OrderedSet the same big-Oh running times as regular sets including O(1) adds, removes, and lookups as well as O(n) iteration.

__len__(self)
__contains__(self, key)
add(self, key)

Add an element.

discard(self, key)

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

__iter__(self)
__reversed__(self)
pop(self, last=True)

Return the popped value. Raise KeyError if empty.

__repr__(self)

Return repr(self).

__eq__(self, other)

Return self==value.