# Module /set

Unordered hash set algebraic operations: union, intersection, difference, symmetric-difference, subset?, and superset?.

```tangu
(use /set)
```

## Functions & symbols

### Set

`(Set) -> Set`

Constructs a new empty Set or initializes a Set with the given items.

```tangu
(use /set)
(let s (Set))
(put s "apple")
```

### contains?

`(set/contains? set item) -> Bool`

Returns `true` if `item` is present in `set` in O(1) average time.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Target Set |
| `item` | `Any` | no | Element to check |

```tangu
(set/contains? #{1 2 3} 2) ; -> true
```

### count-of

`(set/count-of set) -> Int`

Returns the number of distinct elements in `set`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Set to measure |

```tangu
(set/count-of #{1 2 3}) ; -> 3
```

### difference

`(set/difference a b) -> Set`

Returns a new `Set` of elements in `a` that are not in `b`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `a` | `Set` | no | Source set |
| `b` | `Set` | no | Set of elements to exclude |

```tangu
(set/difference #{1 2 3} #{2}) ; -> #{1 3}
```

### intersection

`(set/intersection a b) -> Set`

Returns a new `Set` containing elements present in both `a` and `b`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `a` | `Set` | no | First set |
| `b` | `Set` | no | Second set |

```tangu
(set/intersection #{1 2 3} #{2 3 4}) ; -> #{2 3}
```

### into-iter

`(set/into-iter set) -> Iter`

Returns an iterator yielding elements of `set`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Input Set |

```tangu
(set/into-iter #{1 2 3})
```

### put

`(put set item) -> Set`

Inserts an element into the set.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Target set |
| `item` | `Any` | no | Item to insert |

### remove

`(set/remove set item) -> Bool`

Removes `item` from `set` in place, returning `true` if it was present.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Mutable Set |
| `item` | `Any` | no | Element to delete |

```tangu
(set/remove tags "draft")
```

### subset?

`(set/subset? a b) -> Bool`

Returns `true` if every element of `a` also belongs to `b`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `a` | `Set` | no | Candidate subset |
| `b` | `Set` | no | Candidate superset |

```tangu
(set/subset? #{1 2} #{1 2 3}) ; -> true
```

### union

`(set/union a b) -> Set`

Returns a new `Set` containing elements from either `a` or `b`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `a` | `Set` | no | First set |
| `b` | `Set` | no | Second set |

```tangu
(set/union #{1 2} #{2 3}) ; -> #{1 2 3}
```

### values-of

`(values-of set) -> Array`

Returns an Array containing all elements in the set.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `set` | `Set` | no | Set to extract values from |
