# Set Types

A set is a collection of ordinal values of the same Integer or Enum type. The set type defines the range op potential values; for each instance of the set, any number of individual items (from none to all of them) can be contained in the set. Each value can only be contained *once*.

A set type is expressed using the `set of`

keywords, followed by a range of values.

```
type
DayOfTheWeek = public enum (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
var Weekend: set of DayOfTheWeek := [DayOfTheWeek.Sat, DayOfTheWeek.Subn];
if TodaysDay in Weekend then
PartyTime();
```

Sets can be comprised of Enum values (as shown above), or Integer values:

```
type
DaysOfTheMonth: set of 1..31;
var FirstFewPrimeNumbers: set of Integer := [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31];
```

Sets are limited to 64 individual possible values, ensuring they can be stored in an UInt64 value. Sets contauining 32 or less items are stored in an UInt32.

## Operators

The following Operators are supported on sets:

Operator | Meaning |
---|---|

`+` |
Union of two sets: `[a,b,e] + [c,e,f] = [a,b,c,e,f]` |

`-` |
Difference of two sets: `[a,b,c,d] - [a,c] = [b,d]` |

`*` |
Intersection: `[a,b,e] * [c,e,f] = [e]` |

`=` |
Exact equal; only `true` if all elements are the same in both |

`≠` |
Not equal |

`<` |
Subset, `true` if the right side has all elements the left set has, and more |

`>` |
Superset, `true` if the left side has all elements the right set has, and more |

`≤` |
Subset, `true` if equal or if the right side has all elements the left set has |

`≥` |
Superset, `true` if equal or if the left side has all elements the right set has |

`in` |
Check if an enum or integer is in a set: `a in [a, b, c]` |

`not in` |
returns `not (a in b)` . |

**Note** that Oxygene's language level sets are not to be confused with Swift's higher-level `Set<T>`

struct.

## See Also

- Enum Types
`in`

and`not in`

Operators