A set abstraction supporting the basic set operations.
This implementation requires that all elements are hashable, which
implies that elements must not mutate while contained.
Method Summary |
|
__init__ (self,
elements)
Initializes a new HashSet. |
|
__contains__ (self,
element)
Returns true iff this set contains element. |
|
__eq__ (self,
set)
Returns true iff x == y for all elements in self, set. |
|
__len__ (self)
Returns the number of elements in this set. |
|
__ne__ (self,
set)
Returns true iff this set is not equal to set. |
|
__repr__ (self)
Returns a debugging string representation of this set. |
|
__str__ (self)
Returns a string representation of this set. |
|
add (self,
element)
Adds element to this set. |
|
cartesian (self,
s)
Returns the Cartesian product of this set and s. |
|
contains (self,
element)
Returns true iff this set contains element. |
|
difference (self,
s)
Returns the difference of this set and s. |
|
empty (self)
Returns true iff this set is empty. |
|
intersection (self,
s)
Returns the intersection of this set and s. |
|
list (self)
Returns the elements of this set in a list. |
|
remove (self,
element)
Removes element from this set. |
|
union (self,
s)
Returns the union of this set and s. |