finesse.utilities.collections.OrderedSet

Overview

class finesse.utilities.collections.OrderedSet(iterable=None)

Bases: object

An ordered set implementation using an Dictionary to maintain the order of elements. Dictionaries in recent Python versions are all ordered now.

Parameters
iterableiterable, optional

An optional iterable to initialize the ordered set with elements.

Attributes
_dictDict

The internal dictionary used to maintain order and uniqueness of elements.

Methods

add(item)

Add an element to the OrderedSet.

remove(item)

Remove an element from the OrderedSet.

difference_update(iterable)

Remove all elements from the OrderedSet that are also in the provided iterable.

update(iterable)

Add all elements from the provided iterable to the OrderedSet.

clear()

Remove all elements from the OrderedSet.

__contains__(item)

Check if an element is in the OrderedSet.

__iter__()

Return an iterator over the elements of the OrderedSet.

__len__()

Return the number of elements in the OrderedSet.

__repr__()

Return a string representation of the OrderedSet.

Methods

OrderedSet.__init__

Initialize the OrderedSet with an optional iterable of elements.

OrderedSet.add(self, item)

Add an element to the OrderedSet.

OrderedSet.clear(self)

Remove all elements from the OrderedSet.

OrderedSet.copy(self)

Create a shallow copy of this OrderedSet.

OrderedSet.difference(self, other)

Return a new OrderedSet with elements that are the difference between the two.

OrderedSet.difference_update(self, iterable)

Remove all elements from the OrderedSet that are also in the provided iterable.

OrderedSet.issubset(self, other)

Check if this set is a subset of another set.

OrderedSet.remove(self, item)

Remove an element from the OrderedSet.

OrderedSet.union(self, *others)

Return a new OrderedSet with elements from the union of this set and other.

OrderedSet.update(self, iterable)

Add all elements from the provided iterable to the OrderedSet.