2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/SET/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/SET/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/SET.svg?maxAge=3600)](https://github.com/RobTillaart/SET/releases)
|
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
# SET
|
|
|
|
|
|
|
|
Arduino library to implement simple SET data structure.
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
## Description
|
2020-11-27 05:33:55 -05:00
|
|
|
|
|
|
|
The set library implements the set data structure for integers 0..255.
|
|
|
|
This limit is chosen because of the memory limitations of an Arduino UNO,
|
|
|
|
however these numbers can be used as indices to a table of strings or other
|
|
|
|
datatypes.
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
|
|
|
### Set level
|
2020-11-27 05:33:55 -05:00
|
|
|
- **clr()** empty the set
|
|
|
|
- **invert()** flip all elements in the set.
|
|
|
|
- **count()** returns number of elements
|
|
|
|
- **isEmpty()** idem
|
|
|
|
- **isFull()** idem
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Element level
|
2020-11-27 05:33:55 -05:00
|
|
|
- **add(n)** add element to the Set
|
|
|
|
- **sub(n)** emove element from Set
|
|
|
|
- **invert(n)** flip element in Set
|
|
|
|
- **has(n)** element is in Set
|
|
|
|
- **add(n)**
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Operators
|
2020-11-27 05:33:55 -05:00
|
|
|
- union + +=
|
|
|
|
- diff - -=
|
|
|
|
- intersection * *=
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Equality
|
2020-11-27 05:33:55 -05:00
|
|
|
- equal ==
|
|
|
|
- not equal !=
|
|
|
|
- is subSet <=
|
|
|
|
|
|
|
|
A superSet B is not implemented as one could say B subSet A (B <= A)
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Iterators
|
|
|
|
|
|
|
|
all returns value or -1 if not exist
|
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
- **first()** find first element
|
|
|
|
- **next()** find next element
|
|
|
|
- **prev()** find previous element
|
|
|
|
- **last()** find last element
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
## Operational
|
2020-11-27 05:33:55 -05:00
|
|
|
|
|
|
|
See examples
|