- Name
- Array
- Version
- 1.2.1
- License
- BSD
- URL
- https://github.com/janelia-arduino/Array
- Author
- Peter Polidoro
- [email protected]
An array container similar to the C++ std::array, with some std::vector methods added. The maximum size is fixed as a template parameter, but the size is variable, like a vector. Values can be pushed and popped and the size adjusts accordingly. The data are stored internally as a statically allocated c style array. Care must be taken not to dereference an empty array or access elements beyond bounds.
This library is very similar to Vector, however Vector stores data externally, outside the container, and this library stores data internally. The pointer to the external memory causes the Vector container to use more memory than this container, but storing the data internally makes it necessary to use the maximum size as a class template parameter.
const int ELEMENT_COUNT_MAX = 5;
Array<int,ELEMENT_COUNT_MAX> array;
array.push_back(77);
const int ELEMENT_COUNT_MAX = 5;
int storage_array[ELEMENT_COUNT_MAX];
Vector<int> vector(storage_array);
vector.push_back(77);