Framework (A-Z)

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

Class

Vector

Name

copyInto()

Examples
Vector < int > intVector;
// declares an array of ints with 11 positions
int arrayOfInts[11];  

void setup() {
  Serial.begin(9600); 
  // turn ON wiring hardware LED
  pinMode(WLED, OUTPUT);  
  digitalWrite(WLED, HIGH);
  
  // add 10 elements from 0 to 10
  for (int i=0; i<10; i++) {  
    intVector.addElement(i);
  }
  
  // copy the Vector content into an array
  intVector.copyInto(arrayOfInts);  

  Serial.print("The arrayOfInts elements are: ");
  // print all all elements in the array
  for (int i=0; i<10; i++) {  
    Serial.print(arrayOfInts[i], DEC);
    Serial.print(" ");
  }
  Serial.println();
  
  Serial.print("The vector's capacity is: ");
  // print the vector's capacity
  Serial.println(intVector.capacity(), DEC);  
  
  intVector.ensureCapacity(20);
  Serial.print("now the vector's capacity is: ");
  // print the vector's capacity
  Serial.println(intVector.capacity(), DEC);  
  
  Serial.print("The vector's size is: ");
  // print the vector's size
  Serial.println(intVector.size(), DEC);  
  
  intVector.setSize(5);
  Serial.print("now the vector's size is: ");
  // print the vector's size
  Serial.println(intVector.size(), DEC);  
 
  Serial.print("The vector's capacity is: ");
  // print the vector's capacity
  Serial.println(intVector.capacity(), DEC);  
  intVector.trimToSize();
  Serial.print("now the vector's capacity is: ");
  // print the vector's capacity  
  Serial.println(intVector.capacity(), DEC);  
}


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 an Array. The array must be big enough to hold all the objects in this vector.
Syntax
vector.copyInto(data)
Parameters
vector a variable of type Vector
data an array of int, long or char
Usage Application
Updated on July 07, 2011 11:09:23pm PDT

Creative Commons License