include algorithm, vector in C++11
int *arr = NULL;
arr = (int *) malloc(sizeof(int) * len);
std::vector<int> arrv(arr, arr+len);
int temp; cin >> temp;
arrv.push_back(temp); // add an element to the array
std::sort(arrv.begin(), arrv.end()); // MERGE SORT
arrv.clear(); // empty the array
include vectory, utility
vector<pair<int, int>> arrv;
arrv.push_back(make_pair(7, 8));
for (const auto &n : arrv) { cout << n.first << ", " << n.second; }
include unordered_map, string in C++11
char *key = "TEST";
int value = 10;
unordered_map<string, int> hashmap = { };
hashmap.insert({ key, value });
hashmap.insert({ "test", 55 });
cout << hashmap["test"];
cout << hashmap[key];
for (const auto &n : hashmap) {
cout << n.first << "=" << n.second;
}
cout << hashmap["key not there"] << " must be 0" << endl;
unordered_map<string, int> copy_map = { };
copy_map.insert(hashmap.begin(), hashmap.end());
hashmap["test"] += 5;
- max heap => root is the max element