Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vovagorodok/arrayutils
Map as array of pairs with constexpr constructors
https://github.com/vovagorodok/arrayutils
arduino array arrays platformio
Last synced: 2 months ago
JSON representation
Map as array of pairs with constexpr constructors
- Host: GitHub
- URL: https://github.com/vovagorodok/arrayutils
- Owner: vovagorodok
- License: mit
- Created: 2022-10-18T21:33:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-10T17:34:13.000Z (6 months ago)
- Last Synced: 2024-08-11T14:01:37.956Z (6 months ago)
- Topics: arduino, array, arrays, platformio
- Language: C++
- Homepage:
- Size: 128 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Array Utils
Allows constexpr construction by:
Function `makeArray()` to create array of types with complex constructions.
Function `makePairArray()` to create mapped arrays.Allows search:
Functions `findByKey()`, `find()` to find pair in array using key.
Function `findByValue()` to find pair in array using value.Array based containers:
Classes `SmallVector` and `SmallMap`.## Pair array advanteges
- Zero memory overhead and the same size as `std::array`
- Can be stored on static mamory or stack
- Linear search is ~3x faster than `std::maps` for small number of elements
- Doesn't require `operator<` or hashRecommended to replace `std::map` when number of elements is less than 15.
When number of elements is greater than 1000 `std::unordered_map` is recommended.
More about tests in TESTS.md.## Configuration
Library requires STL with c++17 or greater.
For PlatformIO. Add to `platformio.ini`:
```
build_flags =
-std=c++17
-std=gnu++17
build_unflags =
-std=gnu++11
```For Arduino IDE. At boards package installation folder create `platform.local.txt`:
```
compiler.cpp.extra_flags=-std=c++17
```