standard template libraries

Posted on 2005-05-07
Last Modified: 2010-04-01
I need to know how with STL I can use associative arrays, please provide code examples.
Question by:Buffon
    LVL 55

    Expert Comment

    by:Jaime Olivares
    You have to use STL map object. Have a look to a previous discussion:
    LVL 11

    Author Comment

    I saw this declaration:

    typedef map<string,string> line;

    as I understand it, it declares something like hashtable (value + key), so in declaration first "string" represents key or value?
    LVL 55

    Expert Comment

    by:Jaime Olivares
    >as I understand it, it declares something like hashtable (value + key), so in declaration first "string"
    >represents key or value?
    No, there is an non-standard hash_map<> collection class in some STL implementations.
    Map usually have some internal implementation of tree (binary, balanced, etc....) but there is no a rule about this. Anyway, this is transparent to the user.
    LVL 55

    Accepted Solution

    >so in declaration first "string" represents key or value?
    Yes, first argument is the key

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now