Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions framework/libraries/HashMap/Examples/HelloHashMap/HelloHashMap.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <HashMap.h>

//define hashmap storage variable
HashMap<String, int> hashMap;

void setup(){

Serial.begin(9600);

//putting object into hashmap variable
hashMap.put("name",18);
hashMap.put("test",200);
hashMap.put("qwer",1234);
hashMap.put("abc",123);
hashMap.put("AlphaBeta",20);

//getting value
Serial.println(hashMap.getValue("qwer")); //print 1234


//containsKey function
Serial.println(hashMap.containsKey("test")); //print 1

Serial.println(hashMap.containsKey("ciaociao")); //print 0


//length
Serial.println(hashMap.length()); //print 5

//remove
hashMap.remove("abc"); //remove object that is associated to "abc" key

Serial.println(hashMap.length()); //print 4


}

void loop(){/*nothing to loop*/}
Loading