-
Notifications
You must be signed in to change notification settings - Fork 81
Click data structures
Tom Barbette edited this page Apr 10, 2024
·
1 revision
Click has its own data structures, similar to the stdlib in many cases. The original Click can't use the std because it's not available in the kernel. Even if your element is only intended for userlevel, the Click libs are built for speed and generally avoid memory allocation.
#include <click/string.hh>
It is not really a data structure, but it is worth mentioning Click has its own String class. Usage is very similar to std::string.
#include <click/vector.hh>
Quite similar to std::vector, an array.
Sample usage :
Vector<int> array;
array.resize(100);
array[50] = 12;
#include <click/hashmap.hh>
A hashtable.
Sample usage :
HashTable<String,int> hm;
hm["hello"] = 42;
for (auto it = hm.begin(); it!=hm.end(); it++) {
click_chatter("Key is %s, value is %d", it->first.c_str(), it->second);
}