Руководство по стандартной библиотеке шаблонов STL


Mmap1


#include <iostream.h> #include <stl.h>

int main () { typedef multimap<char, int, less<char> > mmap; mmap m; cout << "count ('X') = " << m.count ('X') << endl; m.insert (pair<const char, int> ('X', 10)); // Standard way. cout << "count ('X') = " << m.count ('X') << endl; m.insert ('X', 20); // Non-standard, but very convenient! cout << "count ('X') = " << m.count ('X') << endl; m.insert ('Y', 32); mmap::iterator i = m.find ('X'); // Find first match. while (i != m.end ()) // Loop until end is reached. { cout << (*i).first << " -> " << (*i).second << endl; i++; } int count = m.erase ('X'); cout << "Erased " << count << " items" << endl; return 0; }




Начало  Назад  Вперед



Книжный магазин