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
This is a discussion on alternative map class template within the C++ Programming forums, part of the General Programming Boards category; Hi, i'm looking for an alternative, not so complex (very simple) version of the std::map ( map - C++ Reference ...
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.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
thank you, i'm sure it won't be as efficientdo 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.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
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.
Manasij Mukherjee | gcc-4.8.0 @Arch Linux
Slow and Steady wins the race... if and only if :
1.None of the other participants are fast and steady.
2.The fast and unsteady suddenly falls asleep while running !