dsa.hashset module
Module containing a HashSet class implemented using HashTable.
- class dsa.hashset.HashSet(capacity=10)
Bases:
objectA set implementation using a hash table for storage.
- add(item)
Add an item to the set.
- Parameters:
item – The item to add.
- contains(item)
Check if an item is in the set.
- Parameters:
item – The item to check.
- classmethod from_list(iterable=None)
Construct a hash set from an iterable.
- Parameters:
iterable – An optional iterable of initial elements.
- remove(item)
Remove an item from the set.
- Parameters:
item – The item to remove.
- to_list()
Convert the hash set to a list.
- Returns:
A list of the items in the set.
- Return type:
list