Hi, i'm looking for an alternative, not so complex (very simple) version of the std::map (map - C++ Reference) class template. (for study) Can somebody point me to the right direction? Thanks in advance, pumi
Hi, i'm looking for an alternative, not so complex (very simple) version of the std::map (map - C++ Reference) class template. (for study) Can somebody point me to the right direction? Thanks in advance, pumi
Well you could try implementing your own version.
Start with
It won't be as efficient as the standard implementation, but you should be able to explore all the concepts (and implement the API).Code:struct elem { int key, int value }; vector<elem> map;
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thank you, i'm sure it won't be as efficient do you know any "already ready" alternatives?
I thought you wanted a "very simple" one to "study"?
"efficient" implementations are always going to be "complicated" and not something you could "study" in a short time frame.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
AFAIK
std::map is a binary search tree abstracted away under that nice interface.
If you're familiar with trees, implementing one yourself would be educational.