alternative map class template

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 ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    2

    alternative map class template

    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

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    Well you could try implementing your own version.

    Start with
    Code:
    struct elem { int key, int value };
    vector<elem> map;
    It won't be as efficient as the standard implementation, but you should be able to explore all the concepts (and implement the API).
    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.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    2
    thank you, i'm sure it won't be as efficient do you know any "already ready" alternatives?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    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.

  5. #5
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,523
    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.9.2 @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 !



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-30-2011, 04:28 PM
  2. Template class nested in template class
    By yahn in forum C++ Programming
    Replies: 7
    Last Post: 04-18-2009, 12:40 PM
  3. Replies: 4
    Last Post: 11-01-2006, 02:23 PM
  4. Template <class T1, class T2, class T3> error LNK2019
    By JonAntoine in forum C++ Programming
    Replies: 9
    Last Post: 10-11-2004, 01:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21