# Sets

A **set** is an
abstract data type
representing an unordered collection of unique elements. Sets behave like
maps
, but only store a single value (analogous to the key in a map), rather than mapping a key to another value.

## Common operations

Name | Description |
---|---|

`size()` |
gets the number of elements in the set |

`contains(e)` |
returns whether element `e` is contained in the set |

`add(e)` |
adds element `e` to the set |

`remove(e)` |
removes element `e` from the set, if it exists |

Sets are commonly implemented using hash tables or binary search trees , since they facilitate rapid lookup for unordered collections of data.