Skip to content
/ Vector Public
forked from janelia-arduino/Vector

A sequence container similar to the C++ std::vector, but instead of allocating memory dynamically, this container points to an external, statically allocated c style array.

License

Notifications You must be signed in to change notification settings

coc/Vector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vector

Library Information

Name
Vector
Version
1.2.1
License
BSD
URL
https://github.com/janelia-arduino/Vector
Author
Peter Polidoro
Email
[email protected]

A sequence container similar to the C++ std::vector, but instead of allocating memory dynamically, this container points to an external, statically allocated c style array. The maximum size is fixed at compile time, but the size can change by pushing and popping elements from the vector. Static memory allocation is used to avoid dynamic allocation problems on very small embedded processors. Care must be taken not to dereference an empty vector, access elements beyond bounds, or use without setting the storage array.

This library is very similar to Array, however Array stores data internally in the container and this library stores data externally. The pointer to the external memory causes this container to use more memory than the Array container, but storing the data externally avoids needing the maximum size as a class template parameter.

Vector vs Array

Vector

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

Array

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

About

A sequence container similar to the C++ std::vector, but instead of allocating memory dynamically, this container points to an external, statically allocated c style array.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 100.0%