Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CHAPTER5-22.cpp
Package: c++stl程序员开发指南.rar [view]
Upload User: fjc899
Upload Date: 2007-07-03
Package Size: 187k
Code Size: 1k
Category:
STL
Development Platform:
C/C++
- //文件名:CHAPTER5-22.cpp
- #include <map>
- #include <iostream>
- using namespace std;
- struct ltstr{
- bool operator()(const char* s1, const char* s2) const
- {
- return strcmp(s1, s2) < 0;
- };
- };
- int main()
- {
- multimap<const char*, int, ltstr> m;
- m.insert(pair<const char* const, int>("a", 1));
- m.insert(pair<const char* const, int>("c", 2));
- m.insert(pair<const char* const, int>("b", 3));
- m.insert(pair<const char* const, int>("b", 4));
- m.insert(pair<const char* const, int>("a", 5));
- m.insert(pair<const char* const, int>("b", 6));
- cout << "Number of elements with key a: " << m.count("a") << endl;
- cout << "Number of elements with key b: " << m.count("b") << endl;
- cout << "Number of elements with key c: " << m.count("c") << endl;
- cout << "Elements in m: " << endl;
- for (multimap<const char*, int, ltstr>::iterator it = m.begin();it != m.end();++it)
- cout << " [" << (*it).first << ", " << (*it).second << "]" << endl;
- }