| Vector

| Reference for Wiring 1.0 (ALPHA) 0022+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Class |  | Vector
Name |  | ### copyInto
Examples |  |
    Vector <int> intVector;
    int arrayOfInts[11];  // declares an array of ints with 11 positions

    void setup() {
      Serial.begin(9600);
      pinMode(48, OUTPUT);  // turn ON wiring hardware LED
      digitalWrite(48, HIGH);

      for(int i=0; i<10; i++) {  // add 255 elements from 0 to 254
        intVector.addElement(i);
      }

      intVector.copyInto(arrayOfInts);  // copy the Vector content into an array

      Serial.print("The arrayOfInts elements are: ");
      for(int i=0; i<10; i++) {  // print all all elements in the array
        Serial.print(arrayOfInts[i], DEC);
        Serial.print(" ");
      }
      Serial.println();

      Serial.print("The vector's capacity is: ");
      Serial.println(intVector.capacity(), DEC);  // print the vector's capacity
      intVector.ensureCapacity(20);
      Serial.print("now the vector's capacity is: ");
      Serial.println(intVector.capacity(), DEC);  // print the vector's capacity

      Serial.print("The vector's size is: ");
      Serial.println(intVector.size(), DEC);  // print the vector's size
      intVector.setSize(5);
      Serial.print("now the vector's size is: ");
      Serial.println(intVector.size(), DEC);  // print the vector's size

      Serial.print("The vector's capacity is: ");
      Serial.println(intVector.capacity(), DEC);  // print the vector's capacity
      intVector.trimToSize();
      Serial.print("now the vector's capacity is: ");
      Serial.println(intVector.capacity(), DEC);  // print the vector's capacity
    }

    void loop() {

    }
Description |  | Copies the components of this vector into the specified array. The item at index k in this vector is copied into component k of anArray. The array must be big enough to hold all the objects in this vector.
Syntax |  |
    copyInto(data)
Parameters |  |
data |  | an array of int, long or char
Usage |  | Application