-
Notifications
You must be signed in to change notification settings - Fork 0
Ned Bingham edited this page Mar 23, 2017
·
2 revisions
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.
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.
#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;
}