Sets are a collection of objects:
- They might be ordered or unordered.
- Two variants:
- Single instance of any object.
- Multiple instances.
Maps associate a value or values with a key:
- They might be ordered or unordered.
- Two variants:
- Single value per key.
- Multiple values per key.
Example:
#include <map>
std::map<size_t, std::string> map;
map[0] = "Hello";
map[1] = "you";
map[2] = "there!";
Example in C++:
#include <map>
#include <string>
using namespace std;
int main() {
map<int, string> sample_map;
sample_map.insert(pair<int, string>(1, "one"));
sample_map.insert(pair<int, string>(2, "two"));
cout << sample_map[1] << " " << sample_map[2] << endl;
}
Another example but needs C++11:
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
map<int, string> sample_map { { 1, "one"}, { 2, "two" } };
cout << sample_map[1] << " " << sample_map[2] << endl;
}
C++ has great built-in support for these, C does not.
Resources
Failure
Error: There is another generation process
plugin:obsidian-textgenerator-plugin:56949 TextGenerator.eval plugin:obsidian-textgenerator-plugin:56949:31
Generator.next
plugin:obsidian-textgenerator-plugin:78 eval plugin:obsidian-textgenerator-plugin:78:61
new Promise
plugin:obsidian-textgenerator-plugin:62 __async plugin:obsidian-textgenerator-plugin:62:10
plugin:obsidian-textgenerator-plugin:56935 TextGenerator.generate plugin:obsidian-textgenerator-plugin:56935:12
plugin:obsidian-textgenerator-plugin:58440 AutoSuggest.eval plugin:obsidian-textgenerator-plugin:58440:52
Generator.next
plugin:obsidian-textgenerator-plugin:78 eval plugin:obsidian-textgenerator-plugin:78:61
new Promise