Librerías \ HashMap

Referencia para la versión de Wiring 1.0 Build 0100+. Si tiene una versión previa, use la referencia incluida con su software. Si encuentra errores o tiene comentarios, no dude en contactarnos.

Clase

HashMap

Nombre

size()

Ejemplos
#include <HashMap.h>
//create hashMap that pairs char* to int and can hold 3 pairs
CreateHashMap(hashMap, char*, int, 3); 

void setup()
{
  Serial.begin(9600);
  //add and store keys and values
  hashMap["newKey"] = 12;
  hashMap["otherKey"] = 13;

  //check if overflow (there should not be any danger yet)
  Serial.print("Will the hashMap overflow now [after 2 assigns] ?: ");
  Serial.println(hashMap.willOverflow());

  hashMap["lastKey"] = 14;

  //check if overflow (this should be true, as we have added 3 of 3 pairs)
  Serial.print("Will the hashMap overflow now [after 3 assigns] ?: ");
  Serial.println(hashMap.willOverflow());

  //it will overflow, but this won't affect the code.
  hashMap["test"] = 15;

  //change the value of newKey
  Serial.print("The old value of newKey: ");
  Serial.println(hashMap["newKey"]);

  hashMap["newKey"]++;

  Serial.print("The new value of newKey (after hashMap['newKey']++): ");
  Serial.println(hashMap["newKey"]);

  //remove a key from the hashMap
  hashMap.remove("otherKey");

  //this should work as there is now an availabel spot in the hashMap
  hashMap["test"] = 15;

  printHashMap();
}

void loop() {
}

void printHashMap() 
{
  for (int i=0; i<hashMap.size(); i++) 
  {
    Serial.print("Key: ");
    Serial.print(hashMap.keyAt(i));
    Serial.print(" Value: ");
    Serial.println(hashMap.valueAt(i));
  }
}
Descripción Obtiene el tamaño de este HashMap.
Sintaxis
size()
Retorna int: El tamaño de este HashMap.
Uso Application
Updated on July 07, 2011 11:15:04pm PDT

Creative Commons License