int main(void) { RandomizedCollection collection; // cout << boolalpha << collection.insert(1) << "\tPassed\n"; // cout << boolalpha << collection.insert(1) << "\tPassed\n"; // cout << boolalpha << collection.insert(2) << "\tPassed\n"; // cout << collection.getRandom() << "\tPassed\n"; // cout << boolalpha << collection.remove(1) << "\tPassed\n"; // cout << collection.getRandom() << "\tPassed\n"; cout << boolalpha << collection.insert(1) << "\tPassed\n"; cout << boolalpha << collection.remove(2) << "\tPassed\n"; cout << boolalpha << collection.insert(2) << "\tPassed\n"; cout << collection.getRandom() << "\tPassed\n"; cout << boolalpha << collection.remove(1) << "\tPassed\n"; cout << boolalpha << collection.insert(2) << "\tPassed\n"; cout << collection.getRandom() << "\tPassed\n"; cout << "\nPassed All\n"; return 0; }
int main() { { RandomizedCollection c; assert(true == c.insert(1)); assert(false == c.insert(1)); assert(true == c.insert(2)); assert(false == c.insert(1)); assert(false == c.insert(2)); assert(false == c.insert(2)); assert(true == c.remove(1)); assert(true == c.remove(2)); assert(true == c.remove(2)); assert(true == c.remove(2)); } { RandomizedCollection c; assert(true == c.insert(0)); assert(true == c.remove(0)); assert(true == c.insert(-1)); assert(false == c.remove(0)); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); assert(-1 == c.getRandom()); } { RandomizedCollection c; assert(true == c.insert(0)); assert(true == c.remove(0)); assert(false == c.remove(0)); assert(true == c.insert(0)); assert(0 == c.getRandom()); } return 0; }