Giter VIP home page Giter VIP logo

arduino_vector's Introduction

Arduino_Vector

Lightweight implementation of the STL vector for Arduino

Dynamic memory management on a microcontroller can lead to overflows if not managed carefully.

###But... I've wanted to use a vector to store a limited number of objects like pointers to different sensors on my robot or a list of 10 control options to manuever based off the sonar's data. Instead of using an array I decided to implement the C++ STL vector with limited functionality to keep the code size small and the operations focused on teh basics.

This first verion on my Vector has the basics you expect.

a. No penatly for construction

Vector<foo> vf; //sizof(vf) == 0 until you push_back into it.

b. Normal C++ push_back for appending data to the end of the vector

vf.push_back(foo);

c. Normal access operator

vf[0] = foo2;

d. Normal .size() method for traversing the vector

    for(int i=0; i<vf.size(); ++i) {
      Serial.print("foo is: ");
      Serial.println(vf[i]);
    }

Behind the scenes vector acquires free store memory and releases it using the same mechanisms as the STL containter.

Installation

  1. From the command line 'cd' into the Arduino/libraries folder.
  2. Enter 'git clone http://github.com/zacsketches/Arduino_Vector.git'
  3. This will clone the library into your Arduino libraries.
  4. Restart the Arduino IDE. Click on examples and you will see the Vector library and the Vector_use example.

arduino_vector's People

Contributors

zacsketches avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.