Programming With Vectors

I’m trying to use vectors in a sketch. Adding #include gives compiler error that no such file exists. I found the file so tried #include < /usr/include/c++/4.6/vector>. It found that OK, but gave compiler error that it did not find the include files that are referenced in that file.

I really want to use vectors because I need to add an unknown number of arrays while a sketch runs.

Thanks in advance

have you tried looking at the menu option:
Sketch > Import Library... > Add Library...

Adding #include gives compiler error that no such file exists.

What happens if you try:

#include <vector.h>



I just did try that but vector is not listed as one of the available libraries. Did not find Add Library under Import Library. But found Sketch>Add File. Used this to find the vector file but that did not work either.


Under File:Prefences, there is a path
Under that path there is a /libraries folder, create a /vector folder
/vector folder needs to include the vector.h file

Keep in mind Uno/'328P based boards only have 2048 bytes of SRAM for all that vector stuff.

CrossRoads, Thanks, that seems to be the best thing to try.

"Vector" is a class implemented by the C++ Standard library and Standard Template Library. Arduino doesn't have those (avr-gcc doesn't have those either.) " Vectors are sequence containers representing arrays that can change in size." (This is generally considered a bad idea on systems as small as an AVR, with 2K of memory. You're better off allocating an array as big as the maximum size you'll need.)

You can write it yourself, or try to import an existing implementation, or use something similar like the C library; it depends on what the actual needs of your program are. As you've noticed, trying to use a standard implementation is likely to lead you down a road to "dependency hell." :frowning:

Are you trying to use "vectors" as a variable length array, or "vectors" as a geometric concept , which for normal purposes are arrays with three elements ?