OrderedSet

class orderedsets.OrderedSet(items: ~typing.Iterable[~orderedsets.T] | ~typing.Type[~orderedsets._NotProvided] = <class 'orderedsets._NotProvided'>)[source]

Bases: AbstractSet[T]

A set class that preserves insertion order.

It can be used as a drop-in replacement for set where ordering is desired.

__init__(items: ~typing.Iterable[~orderedsets.T] | ~typing.Type[~orderedsets._NotProvided] = <class 'orderedsets._NotProvided'>) None[source]

Create a new OrderedSet, optionally initialized with items.

__eq__(other: object) bool[source]

Return whether this set is equal to other.

__repr__() str[source]

Return a string representation of this set.

add(element: T) None[source]

Add element to this set.

clear() None[source]

Remove all elements from this set.

copy() OrderedSet[T][source]

Return a shallow copy of this set.

difference(*others: Iterable[T]) OrderedSet[T][source]

Return all elements that are in this set but not in others.

difference_update(*others: Iterable[T]) None[source]

Update this set to remove all items that are in others.

discard(element: T) None[source]

Remove element from this set if it is present.

intersection(*others: Iterable[T]) OrderedSet[T][source]

Return a new set with elements common to this set and all others.

intersection_update(*others: Iterable[T]) None[source]

Update this set to be the intersection of itself and others.

isdisjoint(s: Iterable[T]) bool[source]

Return whether this set is disjoint with s.

issubset(s: Iterable[T]) bool[source]

Return whether this set is a subset of s.

issuperset(s: Iterable[T]) bool[source]

Return whether this set is a superset of s.

pop() T[source]

Remove and return the most recently added element from this set.

remove(element: T) None[source]

Remove element from this set, raising KeyError if not present.

symmetric_difference(s: Iterable[T]) OrderedSet[T][source]

Return the symmetric difference of this set and s.

symmetric_difference_update(s: Iterable[T]) None[source]

Update this set to be the symmetric difference of itself and s.

union(*others: Iterable[T]) OrderedSet[T][source]

Return a new set with elements from this set and others.

update(*others: Iterable[T]) None[source]

Update this set to be the union of itself and others.

__len__() int[source]

Return the number of elements in this set.

__contains__(o: object) bool[source]

Return whether o is in this set.

__iter__() Iterator[T][source]

Return an iterator over the elements of this set.

__and__(s: Set[T]) OrderedSet[T][source]

Return the intersection of this set and s.

__iand__(s: Set[T]) OrderedSet[T][source]

Update this set to be the intersection of itself and s.

__or__(s: Set[Any]) OrderedSet[T][source]

Return the union of this set and s.

__ior__(s: Set[Any]) OrderedSet[T][source]

Update this set to be the union of itself and s.

__sub__(s: Set[T]) OrderedSet[T][source]

Return the difference of this set and s.

__isub__(s: Set[T]) OrderedSet[T][source]

Update this set to be the difference of itself and s.

__xor__(s: Set[Any]) OrderedSet[T][source]

Return the symmetric difference of this set and s.

__ixor__(s: Set[Any]) OrderedSet[T][source]

Update this set to be the symmetric difference of itself and s.

__le__(s: Set[T]) bool[source]

Return whether this set is a subset of s.

__lt__(s: Set[T]) bool[source]

Return whether this set is a proper subset of s.

__ge__(s: Set[T]) bool[source]

Return whether this set is a superset of s.

__gt__(s: Set[T]) bool[source]

Return whether this set is a proper superset of s.

FrozenOrderedSet

class orderedsets.FrozenOrderedSet(items: ~typing.Iterable[~orderedsets.T] | ~typing.Type[~orderedsets._NotProvided] = <class 'orderedsets._NotProvided'>)[source]

Bases: AbstractSet[T]

A frozen set class that preserves insertion order.

It can be used as a drop-in replacement for frozenset where ordering is desired.

__init__(items: ~typing.Iterable[~orderedsets.T] | ~typing.Type[~orderedsets._NotProvided] = <class 'orderedsets._NotProvided'>) None[source]

Create a new FrozenOrderedSet, optionally initialized with items.

__hash__() int[source]

Return a hash of this set.

__eq__(other: object) bool[source]

Return whether this set is equal to other.

__repr__() str[source]

Return a string representation of this set.

__len__() int[source]

Return the number of elements in this set.

__contains__(o: object) bool[source]

Return whether o is in this set.

__iter__() Iterator[T][source]

Return an iterator over the elements of this set.

copy() FrozenOrderedSet[T][source]

Return a shallow copy of this set.

difference(*others: Iterable[T]) FrozenOrderedSet[T][source]

Return the difference of this set and others.

intersection(*others: Iterable[T]) FrozenOrderedSet[T][source]

Return the intersection of this set and others.

symmetric_difference(s: Iterable[T]) FrozenOrderedSet[T][source]

Return the symmetric difference of this set and s.

isdisjoint(s: Iterable[T]) bool[source]

Return whether this set is disjoint with s.

issubset(s: Iterable[T]) bool[source]

Return whether this set is a subset of s.

issuperset(s: Iterable[T]) bool[source]

Return whether this set is a superset of s.

union(*others: Iterable[T]) FrozenOrderedSet[T][source]

Return the union of this set and others.

__and__(s: Set[T]) FrozenOrderedSet[T][source]

Return the intersection of this set and s.

__or__(s: Set[Any]) FrozenOrderedSet[T][source]

Return the union of this set and s.

__sub__(s: Set[T]) FrozenOrderedSet[T][source]

Return the difference of this set and s.

__xor__(s: Set[Any]) FrozenOrderedSet[T][source]

Return the symmetric difference of this set and s.

Internal stuff that is only here because the documentation tool wants it

class orderedsets.T

A type variable.