#include #include using namespace std; template ostream& operator<<(ostream& out, const unordered_set& obj); int main() { unordered_set floats { 2.3, 6.2, 3.4, 5.6, .78, 5.5, 3.2, 0, 1.7, 2, 4, 4.7, 6.6, 4, 7.3, 5.6, 2.1, 4.4, 5.5 }; cout << "floats.size() = " << floats.size() << endl; for (auto it = floats.cbegin(); it != floats.cend(); ++it) { cout << *it << " "; } cout << endl; float temp = 2.4; cout << temp << " is " << (floats.find(temp) == floats.end() ? "not " : "") << "present\n"; temp = 3.4; cout << temp << " is " << (floats.find(temp) == floats.end() ? "not " : "") << "present\n\n"; floats.erase(3.4); floats.insert(.5); cout << floats << endl; unordered_set ints; for (int i = 0; i < 100; i++) ints.insert(rand()%1000+1); cout << ints << endl; } template ostream& operator<<(ostream& out, const unordered_set& obj) { out << "size = " << obj.size() << endl; out << "number of buckets = " << obj.bucket_count() << endl; for (size_t i = 0; i < obj.bucket_count(); ++i) { if (obj.bucket_size(i)) { out << "bucket #" << i << ": "; for (auto buckIt = obj.cbegin(i); buckIt != obj.cend(i); ++buckIt) out << *buckIt << " "; out << endl; } } return out; }