OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [tests/] [bvt15.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#include "stdtest.h"
7
 
8
typedef multimap<int,string> empmap_t;
9
typedef empmap_t::const_iterator citer_t;
10
 
11
void PrintEntries (citer_t first, citer_t last)
12
{
13
    for (citer_t i = first; i < last; ++ i)
14
        cout << i->second << "\t- $" << i->first << endl;
15
}
16
 
17
inline void PrintEntries (const empmap_t& m)    { PrintEntries (m.begin(), m.end()); }
18
 
19
void TestMultiMap (void)
20
{
21
    empmap_t employees;
22
    employees.insert (make_pair (27000, string("Dave")));
23
    employees.insert (make_pair (27000, string("Jim")));
24
    employees.insert (make_pair (99000, string("BigBoss")));
25
    employees.insert (make_pair (47000, string("Gail")));
26
    employees.insert (make_pair (15000, string("Dumb")));
27
    employees.insert (make_pair (47000, string("Barbara")));
28
    employees.insert (make_pair (47000, string("Mary")));
29
 
30
    cout << "As-inserted listing:" << endl;
31
    PrintEntries (employees);
32
 
33
    cout << "Alphabetical listing:" << endl;
34
    sort (employees);
35
    PrintEntries (employees);
36
 
37
    empmap_t::range_t middles = employees.equal_range (47000);
38
    cout << "Employees making $" << middles.first->first << ":";
39
    empmap_t::const_iterator i;
40
    for (i = middles.first; i < middles.second; ++ i)
41
        cout << " " << i->second;
42
    cout << endl;
43
 
44
    cout << "There are " << employees.count (27000) << " low-paid employees" << endl;
45
 
46
    cout << "Firing all low-paid employees:" << endl;
47
    employees.erase (27000);
48
    PrintEntries (employees);
49
 
50
    cout << "Firing dumb employees:" << endl;
51
    employees.erase (employees.begin(), employees.begin() + 1);
52
    PrintEntries (employees);
53
}
54
 
55
StdBvtMain (TestMultiMap)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.