set#
- swordfish.set(data: Any = None, *, type: DataType = None) Set#
- swordfish.set(*, type: DataType = None, capacity: int = 0) Set
Creates a Swordfish Set from a Python object or initializes one with a specified type and capacity.
There are two modes of initialization:
If
datais provided, it converts the given Python object into a Set of the specifiedtype.If
datais not provided, a new Set is created with the specifiedtypeandcapacity.
- Parameters:
data (Any, optional) – The input data to initialize the Set. Defaults to None.
type (DataType, optional) – The data type for the Set. Defaults to None.
capacity (int, optional) – The initial capacity of the Set (used when
datais None). Defaults to 0.
- Returns:
A Swordfish Set initialized based on the provided arguments.
- Return type:
Examples
- Creating a Set from existing data:
>>> import swordfish as sf >>> sf.set({1, 2, 3}, type="INT") Set(set(3, 2, 1), type=INT)
- Creating an empty Set with a specific type and capacity:
>>> sf.set(type="CHAR", capacity=5) Set(set(), type=CHAR)