STL Containers
Jump to navigation
Jump to search
อยากใช้ STL เป็นเร็วๆ T^T ใครใช้เป็นก็ช่วยๆกันใส่หน่อยละกัน (อ้างอิงมาจาก C++ Reference)
Contents
STL Containers
Sequence containers
vector
deque (Double ended queue)
list
Container adaptors
stack
queue
priority_queue
Associative containers
set
multiset
map
- สามารถใช้ map ทำเป็น 2D-Array (อาเรย์ 2 มิติ) ได้ด้วยคำสั่ง
std::map<int, std::map<int, int> > mymap;
- For example:
#include <map>
#include <iostream>
int main()
{
std::map<int, std::map<int, int> > mymap;
mymap[9][2] = 7;
std::cout << mymap[9][2] << std::endl;
if (mymap.find(9) != mymap.end() && mymap[9].find(2) != mymap[9].end()) {
std::cout << "My map contains a value for [9][2]" << std::endl;
} else {
std::cout << "My map does not contain a value for [9][2]" << std::endl;
}
return 0;
}
//credit: http://stackoverflow.com/questions/3393243/how-to-use-stlmap-as-two-dimension-array