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)
|
2021-12-28 04:38:33 -05:00
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/SET/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/SET/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/SET/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/SET/actions/workflows/jsoncheck.yml)
|
2021-01-29 06:31:58 -05:00
|
|
|
[![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)
|
|
|
|
|
2021-12-28 04:38:33 -05:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
# SET
|
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
Arduino library to implement a simple SET data structure.
|
2020-11-27 05:33:55 -05:00
|
|
|
|
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
|
2021-12-28 04:38:33 -05:00
|
|
|
data types.
|
2020-11-27 05:33:55 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
|
|
|
|
### Constructor
|
|
|
|
|
|
|
|
- **Set(bool clear = true)** creates an empty set, default it is cleared.
|
|
|
|
- **Set(&Set)** copies a set.
|
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Set level
|
2021-05-05 07:46:09 -04:00
|
|
|
|
|
|
|
- **clear()** empty the set.
|
2020-11-27 05:33:55 -05:00
|
|
|
- **invert()** flip all elements in the set.
|
2021-12-28 04:38:33 -05:00
|
|
|
- **addAll()** add all 256 elements to the set.
|
2021-05-05 07:46:09 -04:00
|
|
|
- **count()** returns the number of elements.
|
2020-11-27 05:33:55 -05:00
|
|
|
- **isEmpty()** idem
|
|
|
|
- **isFull()** idem
|
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Element level
|
2021-05-05 07:46:09 -04:00
|
|
|
|
2021-12-28 04:38:33 -05:00
|
|
|
- **add(uint8_t value)** add element n to the Set.
|
|
|
|
- **sub(uint8_t value)** remove element n from the Set.
|
|
|
|
- **invert(uint8_t value)** flip element n in the Set.
|
|
|
|
- **has(uint8_t value)** check if element n is in the Set.
|
2021-05-05 07:46:09 -04:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Operators
|
2021-05-05 07:46:09 -04:00
|
|
|
|
2020-11-27 05:33:55 -05:00
|
|
|
- union + +=
|
|
|
|
- diff - -=
|
|
|
|
- intersection * *=
|
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Equality
|
2021-05-05 07:46:09 -04:00
|
|
|
|
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-05-05 07:46:09 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
### Iterators
|
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
all iterator-functions returns the current element or -1 if not exist.
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-05-05 07:46:09 -04:00
|
|
|
- **setCurrent(n)** if n is in the Set, n will be the current
|
|
|
|
- **first()** find the first element
|
2021-12-28 04:38:33 -05:00
|
|
|
- **next()** find the next element. Will not wrap around when 'end' of the set is reached.
|
|
|
|
- **prev()** find the previous element. Will not wrap around when 'begin' of the set is reached.
|
2021-05-05 07:46:09 -04:00
|
|
|
- **last()** find the last element.
|
2021-05-08 03:51:40 -04:00
|
|
|
- **getNth(n)** find the Nth element in a set if it exist.
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-12-28 04:38:33 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
## Operational
|
2020-11-27 05:33:55 -05:00
|
|
|
|
|
|
|
See examples
|
2021-12-28 04:38:33 -05:00
|
|
|
|
|
|
|
|
|
|
|
## Future
|
|
|
|
|
|
|
|
- update documentation
|
|
|
|
|