Skip to content

janelia-arduino/Array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Array

Library Information

Name
Array
Version
1.2.1
License
BSD
URL
https://github.com/janelia-arduino/Array
Author
Peter Polidoro
Email
peter@polidoro.io

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.

Array vs Vector

Array

const int ELEMENT_COUNT_MAX = 5;
Array<int,ELEMENT_COUNT_MAX> array;
array.push_back(77);

Vector

const int ELEMENT_COUNT_MAX = 5;
int storage_array[ELEMENT_COUNT_MAX];
Vector<int> vector(storage_array);
vector.push_back(77);

About

An array container similar to the C++ std::array, but with variable size and some methods like the std::vector.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages