StructureBuild::FixedSet StructureBuild::getFixedSet() const { FixedSet fixedSet; BOOST_FOREACH(AtomInfoMap::const_reference atomInfo, myAtomsInfo) { if(atomInfo.second->isFixed()) fixedSet.insert(atomInfo.first->getIndex()); } return fixedSet; }
TEST(hash_set, initialization_big) { FixedSet f; static std::default_random_engine g_random_engine; std::unordered_set<int> set; std::vector<int> keys; for (int i = 0; i < 10000; ++i) { int element = std::uniform_int_distribution<int>(-1000000000, 1000000000) (g_random_engine); set.insert(element); keys.push_back(element); } f.Init(keys); for (int i = -1000; i <= 1000; ++i) { ASSERT_TRUE((f.Contains(i)) == (set.find(i) != set.end())); } }
void PrintAnswers(const std::vector<int> &requests, FixedSet &fixed_set, std::ostream& ostream = std::cout) { for (auto number : requests) { bool answer = fixed_set.Contains(number); if (answer) ostream << "Yes\n"; else ostream << "No\n"; } }
TEST(hash_set, initialization) { FixedSet f; std::vector<int> keys {1, 2, 4, 5, 7, 11, 28}; f.Init(keys); ASSERT_TRUE(f.Contains(11)); ASSERT_TRUE(f.Contains(1)); ASSERT_TRUE(f.Contains(2)); ASSERT_FALSE(f.Contains(3)); ASSERT_TRUE(f.Contains(4)); ASSERT_TRUE(f.Contains(5)); ASSERT_FALSE(f.Contains(6)); ASSERT_TRUE(f.Contains(7)); ASSERT_FALSE(f.Contains(8)); ASSERT_FALSE(f.Contains(9)); ASSERT_FALSE(f.Contains(10)); ASSERT_FALSE(f.Contains(29)); }