Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HashTable
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////// //HashTable:Understanding Hash Table where division method is used for hashing //class HashT code credit goes to www.programiz.com & www.educba.com.Template modifications and main driver code are created by Rezaul Hoque on September 04,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; /////////////////////////////////////////////////////////////////////////// #include <iostream> #include <string> #include <list> template <class T> class HashT{ int sz; std::list<T> *tab; public: HashT(int n){ this->sz=n; tab=new std::list<T>[sz];} int HashF(int key) { return key%sz; } void insert (int key, T data){ tab[HashF(key)].push_back(data); } void print(){ int i; for(i=0;i<sz;i++){ std::cout<<i<<" "<<"\n"; for(auto p : tab[i]) std::cout<<"->"<<p<<"\n"; } } }; int main() { std::string s[]={"Hi","Hola","Ni Hao","Salut","Konnichiwa","Salam","Namastey"}; int k[]={112,321,322,234,333,111,200}; int size =sizeof(k)/sizeof(k[0]); HashT<std::string> h(size); for(int r=0;r<size;r++) h.insert(k[r],s[r]); h.print(); return 0; }
run
|
edit
|
history
|
help
0
PRIx64 on gcc
VecHotel
Dar
Test 7(2020)
process memory structure
Pac update
Dar
Gauss v1.1
shell sort
Vectors as Inputs to Map