orderedset package¶
OrderedSet¶
-
class
orderedset.OrderedSet¶ An
OrderedSetobject is an ordered collection of distinct hashable objects.It works like the
settype, but remembers insertion order.It also supports
__getitem__()andindex(), like thelisttype.-
__getitem__(index)¶ Return the elem at index. Raises
IndexErrorif index is out of range.
-
add(self, elem)¶ Add element elem to the set.
-
clear(self)¶ Remove all elements from the set.
-
copy(self)¶ Return type: OrderedSet Returns: a new OrderedSetwith a shallow copy of self.
-
difference(self, other)¶ OrderedSet - otherReturn type: OrderedSet Returns: a new OrderedSetwith elements in the set that are not in the others.
-
difference_update(self, other)¶ OrderedSet -= otherUpdate the
OrderedSet, removing elements found in others.
-
discard(self, elem)¶ Remove element elem from the
OrderedSetif it is present.
-
index(self, elem)¶ Return the index of elem. Rases
ValueErrorif not in the OrderedSet.
-
intersection(self, other)¶ OrderedSet & otherReturn type: OrderedSet Returns: a new OrderedSetwith elements common to the set and all others.
-
intersection_update(self, other)¶ OrderedSet &= otherUpdate the
OrderedSet, keeping only elements found in it and all others.
-
isdisjoint(self, other)¶ Return True if the set has no elements in common with other. Sets are disjoint if and only if their intersection is the empty set.
Return type: bool
-
isorderedsubset(self, other)¶
-
isorderedsuperset(self, other)¶
-
issubset(self, other)¶ OrderedSet <= otherReturn type: bool Test whether the
OrderedSetis a proper subset of other, that is,OrderedSet <= other and OrderedSet != other.
-
issuperset(self, other)¶ OrderedSet >= otherReturn type: bool Test whether every element in other is in the set.
-
pop(self, last=True)¶ Remove last element. Raises
KeyErrorif theOrderedSetis empty.
-
remove(self, elem)¶ Remove element elem from the
set. RaisesKeyErrorif elem is not contained in the set.
-
symmetric_difference(self, other)¶ OrderedSet ^ otherReturn type: OrderedSet Returns: a new OrderedSetwith elements in either the set or other but not both.
-
symmetric_difference_update(self, other)¶ OrderedSet ^= otherUpdate the
OrderedSet, keeping only elements found in either set, but not in both.
-
union(self, other)¶ OrderedSet | otherReturn type: OrderedSet Returns: a new OrderedSetwith elements from the set and all others.
-
update(self, other)¶ OrderedSet |= otherUpdate the
OrderedSet, adding elements from all others.
-