Go Down

Topic: a std::vector like class (dynamic array)  (Read 1 time) previous topic - next topic


This is a light implementation of vector class to use in arduino.

a quick readme explains how to use the class on github.

else, it is
Code: [Select]
pag::vector<my_type> my_var = pag::vector<my_type>(/*size*/);

the main methods are :
  • operator[] (const and non const ref)
  • size(), indicating the number of item contained
  • resize (returns false if fails)
  • .begin() and .end(), to use like a light iterator system.
  • I made the choice not to use push_back and such, because I didn't want to take responsibility for allocating to much resources automatically

Feel free to use and alter it, under the use licence of course (GPL).


I think it is risky to use any code that dynamically allocates memory in the small SRAM available on an Arduino.

Two or three hours spent thinking and reading documentation solves most programming problems.


Go Up