#include <vector>
#include <list>
// Create a vector containing hashes
std::vector<uint32_t> v ;
// Create a list containing hashes
std::list<uint32_t> l ;
char mac[] = "00-B0-D0-63-C2-26";
char mac1[] = "01-B0-D0-63-C2-26";
char mac2[] = "02-B0-D0-63-C2-26";
void setup() {
Serial.begin(115200);
//hash our macs and add to containers..
uint32_t macHash = hash(mac);
v.push_back(macHash);
l.push_back(macHash);
macHash = hash(mac1);
v.push_back(macHash);
l.push_back(macHash);
macHash = hash(mac2);
v.push_back(macHash);
l.push_back(macHash);
Serial.println("vector");
for (int n : v)
Serial.println(n);
if (std::find(v.begin(), v.end(), macHash) == std::end(v))
Serial.println("Not Found"); else Serial.println("Vector:Found Mac Hash");
Serial.println("list");
for (int n : l)
Serial.println(n);
if (std::find(l.begin(), l.end(), macHash) == std::end(l))
Serial.println("Not Found"); else Serial.println("List:Found Mac Hash");
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
//djb2
uint32_t hash(char *str) {
uint32_t hash = 5381;
int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}