Lesson 13 of 24
map மற்றும் unordered_mapmap and unordered_map
10 min 35 XP
map ஒவ்வொரு key-க்கும் ஒரு value, keys வரிசைப்படுத்தப்பட்டிருக்கும் (O(log n)). unordered_map வரிசை இல்லை, ஆனால் சராசரியாக O(1). m[key]++ மூலம் எண்ணுவது மிக எளிது.
A map stores a value per key with keys kept sorted (O(log n)). unordered_map has no order but averages O(1). Counting is as simple as m[key]++.
Example: edit me and press Run
Press Run to see the result here.for (auto& [key, value] : m) என்பது C++17 structured bindings. m[key] என்று படித்தாலே, key இல்லையெனில் 0-உடன் சேர்க்கப்படும்; சோதிக்க மட்டும் count() அல்லது find() பயன்படுத்துங்கள்.
for (auto& [key, value] : m) uses C++17 structured bindings. Reading m[key] inserts the key with 0 if it's missing; use count() or find() just to check.