pkgcraft.types package¶
Submodules¶
pkgcraft.types.ordered module¶
- class pkgcraft.types.ordered.OrderedFrozenSet(iterable=None)¶
Bases:
objectAn
OrderedFrozenSetobject is an immutable, ordered collection of distinct hashable objects.It works like the
settype, but remembers insertion order.It also supports
__getitem__()andindex(), like thelisttype.- __init__(*args, **kwargs)¶
- copy(self)¶
- Return type:
- Returns:
a new
OrderedSetwith a shallow copy of self.
- difference(self, other)¶
OrderedSet - other- Return type:
- Returns:
a new
OrderedSetwith elements in the set that are not in the others.
- index(self, elem)¶
Return the index of elem. Raises
ValueErrorif not in the set.
- intersection(self, other)¶
OrderedSet & other- Return type:
- Returns:
a new
OrderedSetwith elements common to the set 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:
- issubset(self, other)¶
OrderedSet <= other- Return type:
Test whether the
OrderedSetis a proper subset of other, that is,OrderedSet <= other and OrderedSet != other.
- issuperset(self, other)¶
OrderedSet >= other- Return type:
Test whether every element in other is in the set.
- symmetric_difference(self, other)¶
OrderedSet ^ other- Return type:
- Returns:
a new
OrderedSetwith elements in either the set or other but not both.
- union(self, other)¶
OrderedSet | other- Return type:
- Returns:
a new
OrderedSetwith elements from the set and all others.
- class pkgcraft.types.ordered.OrderedSet¶
Bases:
OrderedFrozenSetAn
OrderedSetobject is a mutable, ordered collection of distinct hashable objects.It works like the
settype, but remembers insertion order.It also supports
__getitem__()andindex(), like thelisttype.- add(self, elem) void¶
Add element elem to the set.
- clear(self)¶
Remove all elements from the set.
- difference_update(self, other)¶
OrderedSet -= otherUpdate the
OrderedSet, removing elements found in others.
- discard(self, elem) void¶
Remove element elem from the
OrderedSetif it is present.
- intersection_update(self, other)¶
OrderedSet &= otherUpdate the
OrderedSet, keeping only elements found in it and all others.
- pop(self, bool 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_update(self, other)¶
OrderedSet ^= otherUpdate the
OrderedSet, keeping only elements found in either set, but not in both.
- update(self, other)¶
OrderedSet |= otherUpdate the
OrderedSet, adding elements from all others.