Skip to content
Ned Bingham edited this page Mar 23, 2017 · 2 revisions

std/map.h


template <class ktype, class vtype>
struct map : list<implier<ktype, vtype> >

This structure implements a mapping from keys to values. In this structure, multiple values can be mapped to the same key.

Member Functions

map()

The default constructor, calls the default constructor of list.

iterator insert(ktype key, vtype value)

Places a key-value implier into the map in order sorted by the key.

iterator find(ktype key)

Returns an iterator to the first implier with the given key.

vtype &operator[](ktype key)

Finds the value mapped to the given key and returns it. If there isn't one, a value is inserted with the given key using the default constructor.

Examples

#include <std/ascii_stream.h>
#include <std/map.h>

using namespace core;

int main()
{
    map<int, int> m;
    m.insert(5, 3);
    m.insert(3, 10);
    m.insert(8, 2);
    cout << m << endl;
    return 0;
}

Simple Containers

Standard Containers

Interface Containers

Specialized Containers

Input/Output

Algorithm

Clone this wiki locally