How to store elements in set in insertion order. for example.
setmyset;
myset.insert(\"stack\");
myset.insert(\"overflow\");
what you need is this, very simple and a standard library. Example online compiler link: http://cpp.sh/7hsxo
#include
#include
#include
static std::unordered_set myset;
int main()
{
myset.insert("blah");
myset.insert("blah2");
myset.insert("blah3");
int count = 0;
for ( auto local_it = myset.begin(); local_it!= myset.end(); ++local_it ) {
printf("index: [%d]: %s\n", count, (*local_it).c_str());
count++;
}
printf("\n");
for ( unsigned i = 0; i < myset.bucket_count(); ++i) {
for ( auto local_it = myset.begin(i); local_it!= myset.end(i); ++local_it )
printf("bucket: [%d]: %s\n", i, (*local_it).c_str());
}
}