Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

I will be maintaining my libraries here:
https://bit.ly/pATDBi

I am the lead developer for libraries 
that ship with the Wiring distribution. 
As per version 1.0 -
Wiring will support Arduino boards.
You are welcome to check it out!
https://wiring.org.co/download/
HashMap Library for Arduino
Author:  Alexander Brevig
Contact: alexanderbrevig@gmail.com

Under Construction

Hint: This is NOT a real hashmap, it's a key-value-map. Searching in this "HashMap" is done via simple iteration over all entries, not via hashed-key.


Navigation


Current version

1.0 Beta 2009-07-13: Initial Release


History

1.0 Beta 2009-07-13: Initial Release


Description

HashMap is a library for the Arduino.

It is created to help simplify associating one value with another.


Download, install and import

Download here: Attach:HashMap.zip

Put the HashMap folder in "hardware\libraries\".
In the Arduino IDE, create a new sketch (or open one) and select from the menubar "Sketch->Import Library->HashMap".
Once the library is imported, an '#include <HashMap.h>' line will appear at the top of your Sketch.


Creation

const byte HASH_SIZE = 5;
HashType<char*,int> hashRawArray[HASH_SIZE];
HashMap<char*,int> hashMap = HashMap<char*,int>( hashRawArray , HASH_SIZE );


Functions

byte getIndexOf( hash )

Will return the index of the hash

value getValueOf( hash )

Will return the value associated to hash


Example

  1. #include <HashMap.h>
  2.  
  3. //define the max size of the hashtable
  4. const byte HASH_SIZE = 5;
  5. //storage
  6. HashType<char*,int> hashRawArray[HASH_SIZE];
  7. //handles the storage [search,retrieve,insert]
  8. HashMap<char*,int> hashMap = HashMap<char*,int>( \hashRawArray , HASH_SIZE );
  9.  
  10. void setup(){
  11.   //setup hashmap
  12.   hashMap[0]("name",18);
  13.   hashMap[1]("test",200);
  14.   hashMap[2]("qwer",1234);
  15.   hashMap[3]("abc",123);
  16.   hashMap[4]("AlphaBeta",20);
  17.  
  18.   Serial.begin(9600);
  19.   Serial.println( hashMap.getIndexOf("test"),DEC );
  20.   Serial.println( hashMap.getValueOf("test") );
  21.  
  22.   hashMap.debug();
  23. }
  24.  
  25. void loop(){/*nothing to loop*/}


FAQ

//contact me


Information about this page

Part of AlphaBeta Libraries.
Last Modified: September 14, 2018, at 02:24 AM
By: