Sample of STL
STL范例 ( 一)
容器部分
Vector-------------------------------------------1
r<int>(cout," "));
cout << endl;
(4);
copy(),(),
ostream_iterator<int>(cout," "));
cout << endl;
return 0;
}
OUTPUT:
rint();
return 0;
}
OUTPUT:
irst << " "
*(3).second << endl; cout << endl;
cout << "lower_bound(5): "
*(5) << endl;
cout << "upper_bound(5): "
*(5) << endl;
cout << "equal_range(5): "
*(5).first << " "
*(5).second << endl;
();
}
OUTPUT:
rint();
}
return 0;
}
OUTPUT:
rI++
Taras Taras
rint();
}
return 0;
}
OUTPUT:
irst << " - "
(*It).second
endl;
It++;
}
irst << " - "
(*It).second
endl;
It++;
}
M m3(),());
It = ();
cout << endl << "m3:" << endl;
while ( It != () )
{
cout << (*It).first << " - "
(*It).second
endl;
It++;
}
return 0;
}
OUTPUT:
irst << " - "
(*It).second
endl;
It++;
}
return 0;
}
OUTPUT:
irst << ": ";
for ( Li = It->();
Li != It->(); Li++ )
cout << *Li << " ";
cout << endl;
}
int n = (2);
cout << "count of element with key '2' (0 or 1) is "
n << endl; return 0;
}
OUTPUT:
econd << " ";
It++;
}
cout << endl;
cout << "size of map = " << ()
<< endl;
cout << "map 'm' is " << () ?
"" : "not ") << "empty" << endl << endl;
(),());
cout << "After (),())"
<< endl;
cout << "size of map = " << ()
<< endl;
cout << "map 'm' is " << () ?
: "not ") << "empty" << endl; return 0;
}
OUTPUT:
irst << " - ";
cout << (*It).second << end
CSTL范例大全教程 来自淘豆网www.taodocs.com转载请标明出处.