#include <vector>
std::vector<int> intVector;
std::vector<String> nameVector;
void setup() {
Serial.begin(9600);
// Insert values at the beginning of the vector
for (int i = 0; i < 5; i++) {
intVector.insert(intVector.end(), i);
Serial.print("adding item ");
Serial.println(i);
}
// Print the vector
for (int i : intVector) {
Serial.println(i);
}
// Remove values from the beginning of the vector until it's empty
while (!intVector.empty()) {
intVector.erase(intVector.begin());
// Print the vector again to confirm it's empty
Serial.println("erased item");
for (int i : intVector) {
Serial.println(i);
}
}
// Insert values at the beginning of the vector
for (int i = 0; i < 5; i++) {
nameVector.insert(nameVector.end(), "Test"+String(i));
Serial.print("adding item ");
Serial.println(i);
}
// Print the vector
for (int count=0 ; count < nameVector.size() ; count++) {
Serial.println(nameVector[count]);
}
// Remove values from the beginning of the vector until it's empty
while (!nameVector.empty()) {
nameVector.erase(nameVector.begin());
// Print the vector again to confirm it's empty
Serial.println("erased item");
// Print the vector
for (int count=0 ; count < nameVector.size() ; count++) {
Serial.println(nameVector[count]);
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}