File: maptest.cc

package info (click to toggle)
wvstreams 4.6.1-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,820 kB
  • ctags: 7,837
  • sloc: cpp: 64,203; ansic: 4,154; sh: 4,094; makefile: 549; perl: 402
file content (30 lines) | stat: -rw-r--r-- 667 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <map>
#include <assert.h>
#include "wvstring.h"

using std::map;


int main ()
{
    map<WvString, WvString> mymap;
    fprintf(stderr, "added foo = bar\n");
    mymap["foo"] = "bar";
    fprintf(stderr, "looked up foo = %s\n", mymap.find("foo")->second.cstr());
    mymap.erase("foo");
    assert(mymap.find("foo") == mymap.end());

    mymap["meaw"] = "death";
    mymap["dog"] = "cow";
    mymap["star"] = "trek";
    mymap["star"] = "office";

    // Iterator test
    map<WvString, WvString>::iterator it;

    for (it = mymap.begin(); it != mymap.end(); ++it)
        fprintf(stderr, "Iter test: %s = %s\n",
		it->first.cstr(), it->second.cstr());
}