bool FilterManager::uninstallFilter(Filter *filter) { DPTR_D(FilterManager); QMap<AVPlayer*, QList<Filter*> > map1(d.vfilter_player_map); // NB: copy it for iteration because called code may modify map -- which caused crashes QMap<AVPlayer*, QList<Filter*> >::iterator it = map1.begin(); while (it != map1.end()) { if (uninstallVideoFilter(filter, it.key())) return true; ++it; } QMap<AVPlayer *, QList<Filter *> > map2(d.afilter_player_map); // copy to avoid crashes when called-code modifies map it = map2.begin(); while (it != map2.end()) { if (uninstallAudioFilter(filter, it.key())) return true; ++it; } QMap<AVOutput*, QList<Filter*> > map3(d.filter_out_map); // copy to avoid crashes QMap<AVOutput*, QList<Filter*> >::iterator it2 = map3.begin(); while (it2 != map3.end()) { if (uninstallFilter(filter, it2.key())) return true; ++it2; } return false; }
void print_map(int menu) //맵 출력 { int i,j; if(menu==0) map=map1(); else if(menu==1) map=map2(); else if(menu==2) map=map3(); for(i=0;i<SERO;i++) { for(j=0;j<GARO;j++) { printf("%c",map[SERO][GARO]); } } }
BOOST_AUTO_TEST_CASE_TEMPLATE (test_map_copy_constructor_1, parameters, test_map_parameters) { COMMON_MAP_TEST_SETUP; map_type map1 (RANGE (value_data::values1 ())); map_type map2 (RANGE (value_data::values2 ())); map_type map3 (map1); map_type map4 (map2); BOOST_CHECK_EQUAL (map3, map1); BOOST_CHECK_EQUAL (map4, map2); if (implementation::stable_order) { assert_identical_order (map3, keys_of (map1)); assert_identical_order (map4, keys_of (map2)); } }
void map_not_aligned_on_scalar() { typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType; typedef typename MatrixType::Index Index; Index size = 11; Scalar* array1 = internal::aligned_new<Scalar>((size+1)*(size+1)+1); Scalar* array2 = reinterpret_cast<Scalar*>(sizeof(Scalar)/2+std::size_t(array1)); Map<MatrixType,0,OuterStride<> > map2(array2, size, size, OuterStride<>(size+1)); MatrixType m2 = MatrixType::Random(size,size); map2 = m2; VERIFY_IS_EQUAL(m2, map2); typedef Matrix<Scalar,Dynamic,1> VectorType; Map<VectorType> map3(array2, size); MatrixType v3 = VectorType::Random(size); map3 = v3; VERIFY_IS_EQUAL(v3, map3); internal::aligned_delete(array1, (size+1)*(size+1)+1); }
template<typename MatrixType> void map_class_matrix(const MatrixType& m) { typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; Index rows = m.rows(), cols = m.cols(), size = rows*cols; Scalar s1 = internal::random<Scalar>(); // array1 and array2 -> aligned heap allocation Scalar* array1 = internal::aligned_new<Scalar>(size); for(int i = 0; i < size; i++) array1[i] = Scalar(1); Scalar* array2 = internal::aligned_new<Scalar>(size); for(int i = 0; i < size; i++) array2[i] = Scalar(1); // array3unaligned -> unaligned pointer to heap Scalar* array3 = new Scalar[size+1]; for(int i = 0; i < size+1; i++) array3[i] = Scalar(1); Scalar* array3unaligned = internal::UIntPtr(array3)%EIGEN_MAX_ALIGN_BYTES == 0 ? array3+1 : array3; Scalar array4[256]; if(size<=256) for(int i = 0; i < size; i++) array4[i] = Scalar(1); Map<MatrixType> map1(array1, rows, cols); Map<MatrixType, AlignedMax> map2(array2, rows, cols); Map<MatrixType> map3(array3unaligned, rows, cols); Map<MatrixType> map4(array4, rows, cols); VERIFY_IS_EQUAL(map1, MatrixType::Ones(rows,cols)); VERIFY_IS_EQUAL(map2, MatrixType::Ones(rows,cols)); VERIFY_IS_EQUAL(map3, MatrixType::Ones(rows,cols)); map1 = MatrixType::Random(rows,cols); map2 = map1; map3 = map1; MatrixType ma1 = map1; MatrixType ma2 = map2; MatrixType ma3 = map3; VERIFY_IS_EQUAL(map1, map2); VERIFY_IS_EQUAL(map1, map3); VERIFY_IS_EQUAL(ma1, ma2); VERIFY_IS_EQUAL(ma1, ma3); VERIFY_IS_EQUAL(ma1, map3); VERIFY_IS_APPROX(s1*map1, s1*map2); VERIFY_IS_APPROX(s1*ma1, s1*ma2); VERIFY_IS_EQUAL(s1*ma1, s1*ma3); VERIFY_IS_APPROX(s1*map1, s1*map3); map2 *= s1; map3 *= s1; VERIFY_IS_APPROX(s1*map1, map2); VERIFY_IS_APPROX(s1*map1, map3); if(size<=256) { VERIFY_IS_EQUAL(map4, MatrixType::Ones(rows,cols)); map4 = map1; MatrixType ma4 = map4; VERIFY_IS_EQUAL(map1, map4); VERIFY_IS_EQUAL(ma1, map4); VERIFY_IS_EQUAL(ma1, ma4); VERIFY_IS_APPROX(s1*map1, s1*map4); map4 *= s1; VERIFY_IS_APPROX(s1*map1, map4); } internal::aligned_delete(array1, size); internal::aligned_delete(array2, size); delete[] array3; }
void TemplateMapTest::onEnter() { UnitTestDemo::onEnter(); auto createMap = [this]() { Map<std::string, Node*> ret; for (int i = 0; i < 20; ++i) { auto node = Node::create(); node->setTag(1000 + i); ret.insert(StringUtils::toString(i), node); } return ret; }; // Default constructor Map<std::string, Node*> map1; CCASSERT(map1.empty(), ""); CCASSERT(map1.size() == 0, ""); CCASSERT(map1.keys().empty(), ""); CCASSERT(map1.keys(Node::create()).empty(), ""); // Move constructor Map<std::string, Node*> map2 = createMap(); for (const auto& e : map2) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 2, ""); } // Copy constructor Map<std::string, Node*> map3(map2); for (const auto& e : map3) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 3, ""); } // Move assignment operator Map<std::string, Node*> map4; auto unusedNode = Node::create(); map4.insert("unused",unusedNode); map4 = createMap(); CCASSERT(unusedNode->getReferenceCount() == 1, ""); for (const auto& e : map4) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 2, ""); } // Copy assignment operator Map<std::string, Node*> map5; map5 = map4; for (const auto& e : map5) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 3, ""); } // Check size CCASSERT(map4.size() == map5.size(), ""); for (const auto& e : map4) { CC_UNUSED_PARAM(e); CCASSERT(e.second == map5.find(e.first)->second, ""); } // bucket_count, bucket_size(n), bucket log("--------------"); log("bucket_count = %d", static_cast<int>(map4.bucketCount())); log("size = %d", static_cast<int>(map4.size())); for (int i = 0; i < map4.bucketCount(); ++i) { log("bucket_size(%d) = %d", i, static_cast<int>(map4.bucketSize(i))); } for (const auto& e : map4) { log("bucket(\"%s\"), bucket index = %d", e.first.c_str(), static_cast<int>(map4.bucket(e.first))); } log("----- all keys---------"); // keys and at auto keys = map4.keys(); for (const auto& key : keys) { log("key = %s", key.c_str()); } auto node10Key = map4.at("10"); map4.insert("100", node10Key); map4.insert("101", node10Key); map4.insert("102", node10Key); log("------ keys for object --------"); auto keysForObject = map4.keys(node10Key); for (const auto& key : keysForObject) { log("key = %s", key.c_str()); } log("--------------"); // at in const function constFunc(map4); // find auto nodeToFind = map4.find("10"); CC_UNUSED_PARAM(nodeToFind); CCASSERT(nodeToFind->second->getTag() == 1010, ""); // insert Map<std::string, Node*> map6; auto node1 = Node::create(); node1->setTag(101); auto node2 = Node::create(); node2->setTag(102); auto node3 = Node::create(); node3->setTag(103); map6.insert("insert01", node1); map6.insert("insert02", node2); map6.insert("insert03", node3); CCASSERT(node1->getReferenceCount() == 2, ""); CCASSERT(node2->getReferenceCount() == 2, ""); CCASSERT(node3->getReferenceCount() == 2, ""); CCASSERT(map6.at("insert01") == node1, ""); CCASSERT(map6.at("insert02") == node2, ""); CCASSERT(map6.at("insert03") == node3, ""); // erase Map<std::string, Node*> mapForErase = createMap(); mapForErase.erase(mapForErase.find("9")); CCASSERT(mapForErase.find("9") == mapForErase.end(), ""); CCASSERT(mapForErase.size() == 19, ""); mapForErase.erase("7"); CCASSERT(mapForErase.find("7") == mapForErase.end(), ""); CCASSERT(mapForErase.size() == 18, ""); std::vector<std::string> itemsToRemove; itemsToRemove.push_back("2"); itemsToRemove.push_back("3"); itemsToRemove.push_back("4"); mapForErase.erase(itemsToRemove); CCASSERT(mapForErase.size() == 15, ""); // clear Map<std::string, Node*> mapForClear = createMap(); auto mapForClearCopy = mapForClear; mapForClear.clear(); for (const auto& e : mapForClearCopy) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 2, ""); } // get random object // Set the seed by time srand((unsigned)time(nullptr)); Map<std::string, Node*> mapForRandom = createMap(); log("<--- begin ---->"); for (int i = 0; i < mapForRandom.size(); ++i) { log("Map: random object tag = %d", mapForRandom.getRandomObject()->getTag()); } log("<---- end ---->"); // Self assignment Map<std::string, Node*> mapForSelfAssign = createMap(); mapForSelfAssign = mapForSelfAssign; CCASSERT(mapForSelfAssign.size() == 20, ""); for (const auto& e : mapForSelfAssign) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 2, ""); } mapForSelfAssign = std::move(mapForSelfAssign); CCASSERT(mapForSelfAssign.size() == 20, ""); for (const auto& e : mapForSelfAssign) { CC_UNUSED_PARAM(e); CCASSERT(e.second->getReferenceCount() == 2, ""); } }
int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Map_Test")); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE); size_t table_size = ACE_MAX_ITERATIONS / 2; size_t iterations = ACE_MAX_ITERATIONS; size_t functionality_tests = 1; if (argc > 1) functionality_tests = ACE_OS::atoi (argv[1]); if (argc > 2) table_size = ACE_OS::atoi (argv[2]); if (argc > 3) iterations = ACE_OS::atoi (argv[3]); MAP_MANAGER_ADAPTER map1 (table_size); HASH_MAP_MANAGER_ADAPTER map2 (table_size); ACTIVE_MAP_MANAGER_ADAPTER map3 (table_size); if (functionality_tests) { // Functionality test of the maps. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nMap Manager functionality test\n"))); functionality_test (map1, iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nHash Map Manager functionality test\n"))); functionality_test (map2, iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nActive Map Manager functionality test\n"))); functionality_test (map3, iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); } // Performance test of the maps. KEY *keys = new KEY[iterations]; // Map Manager performance_test (&insert_test, map1, iterations, keys, table_size, ACE_TEXT ("Map Manager (insert test)")); performance_test (&find_test, map1, iterations, keys, table_size, ACE_TEXT ("Map Manager (find test)")); performance_test (&unbind_test, map1, iterations, keys, table_size, ACE_TEXT ("Map Manager (unbind test)")); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); // Hash Map Manager performance_test (&insert_test, map2, iterations, keys, table_size, ACE_TEXT ("Hash Map Manager (insert test)")); performance_test (&find_test, map2, iterations, keys, table_size, ACE_TEXT ("Hash Map Manager (find test)")); performance_test (&unbind_test, map2, iterations, keys, table_size, ACE_TEXT ("Hash Map Manager (unbind test)")); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); // Active Map Manager performance_test (&insert_test, map3, iterations, keys, table_size, ACE_TEXT ("Active Map Manager (insert test)")); performance_test (&find_test, map3, iterations, keys, table_size, ACE_TEXT ("Active Map Manager (find test)")); performance_test (&unbind_test, map3, iterations, keys, table_size, ACE_TEXT ("Active Map Manager (unbind test)")); delete[] keys; ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE); ACE_END_TEST; return 0; }
/*************************************************************************** * @brief GSkymap_healpix_construct ***************************************************************************/ void TestGSky::test_GSkymap_healpix_construct(void) { // Test void constructor test_try("Test void constructor"); try { GSkymap map; test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test correct Healpix constructors test_try("Test correct Healpix constructors"); try { GSkymap ring1("GAL", 1, "RING", 1); GSkymap ring2("GAL", 2, "RING", 1); GSkymap ring4("GAL", 4, "RING", 1); GSkymap ring8("GAL", 8, "RING", 1); GSkymap ring16("GAL", 16, "RING", 1); GSkymap ring32("GAL", 32, "RING", 1); GSkymap ring64("GAL", 64, "RING", 1); GSkymap ring128("GAL", 128, "RING", 1); GSkymap ring256("GAL", 256, "RING", 1); GSkymap ring512("GAL", 512, "RING", 1); GSkymap nest1("GAL", 1, "NEST", 1); GSkymap nest2("GAL", 2, "NEST", 1); GSkymap nest4("GAL", 4, "NEST", 1); GSkymap nest8("GAL", 8, "NEST", 1); GSkymap nest16("GAL", 16, "NEST", 1); GSkymap nest32("GAL", 32, "NEST", 1); GSkymap nest64("GAL", 64, "NEST", 1); GSkymap nest128("GAL", 128, "NEST", 1); GSkymap nest256("GAL", 256, "NEST", 1); GSkymap nest512("GAL", 512, "NEST", 1); GSkymap map1("CEL", 1, "RING", 1); GSkymap map2("CEL", 1, "RING", 2); GSkymap map3("EQU", 1, "RING", 1); GSkymap map4("EQU", 1, "NESTED", 1); test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test Healpix copy constructor test_try("Test Healpix copy constructor"); try { GSkymap ring1("GAL", 1, "RING", 1); GSkymap ring2 = ring1; test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test invalid coordsys in constructor test_try("Test invalid coordsys in constructor"); try { GSkymap map("HOR", 1, "RING", 1); test_try_failure(); } catch (GException::wcs_bad_coords &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test invalid nside in constructor test_try("Test invalid nside in constructor"); try { GSkymap map("GAL", 3, "RING", 1); test_try_failure(); } catch (GException::wcs_hpx_bad_nside &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test invalid ordering in constructor test_try("Test invalid ordering in constructor"); try { GSkymap map("GAL", 2, "SPHERICAL", 1); test_try_failure(); } catch (GException::wcs_hpx_bad_ordering &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test invalid nmaps in constructor test_try("Test invalid nmaps in constructor"); try { GSkymap map("GAL", 2, "NEST", 0); test_try_failure(); } catch (GException::skymap_bad_par &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Exit test return; }
int main() { // Transformation or Data Flow Relation dataFlow(2,2); // [i,j] -> [i,j] dataFlow.name_input_var(1, "i"); dataFlow.name_input_var(2, "j"); Variable_ID i = dataFlow.input_var(1); Variable_ID j = dataFlow.input_var(2); dataFlow.name_output_var(1, "I"); dataFlow.name_output_var(2, "J"); Variable_ID I = dataFlow.output_var(1); Variable_ID J = dataFlow.output_var(2); F_And *root = dataFlow.add_and(); EQ_Handle ieq = root->add_EQ(); ieq.update_coef(i,1); ieq.update_coef(I,-1); EQ_Handle jeq = root->add_EQ(); jeq.update_coef(j,1); jeq.update_coef(J,-1); // dataFlow.prefix_print(); cout << "Data Flow:\t"; dataFlow.print_with_subs(stdout); RelTuple R; R.append(dataFlow); Relation IS(2); IS.name_set_var(1, "i"); IS.name_set_var(2, "j"); Free_Var_Decl n("n"); Variable_ID IS_n = IS.get_local(&n); Variable_ID IS_i = IS.set_var(1); Variable_ID IS_j = IS.set_var(2); F_And *IS_root = IS.add_and(); GEQ_Handle imin = IS_root->add_GEQ(); imin.update_coef(IS_i, 1); imin.update_const(-1); GEQ_Handle imax = IS_root->add_GEQ(); imax.update_coef(IS_n,1); imax.update_coef(IS_i, -1); GEQ_Handle jmin = IS_root->add_GEQ(); jmin.update_coef(IS_j, 1); jmin.update_const(-1); GEQ_Handle jmax = IS_root->add_GEQ(); jmax.update_coef(IS_n,1); jmax.update_coef(IS_j, -1); cout << "IS:\t\t"; IS.print_with_subs(stdout); SetTuple S; S.append(IS); Relation norm(2); norm.name_set_var(1, "i"); norm.name_set_var(2, "j"); i = norm.set_var(1); j = norm.set_var(2); F_And *norm_root = norm.add_and(); EQ_Handle equal = norm_root->add_EQ(); equal.update_const(0); cout << "Relation:\t"; norm.print_with_subs(stdout); // creating MMaps MMap mmtest; // { [t,i] -> [i,j] , "a" } //defining mmtest Relation map(2,2); // making it output 2 vars map.name_input_var(1, "i"); map.name_input_var(2, "j"); Variable_ID t1 = map.input_var(1); Variable_ID i1 = map.input_var(2); map.name_output_var(1, "i"); map.name_output_var(2, "j"); // output var 2 Variable_ID x1 = map.output_var(1); Variable_ID y1 = map.output_var(2); // output var 2 F_And *map_root = map.add_and(); EQ_Handle map_xeq = map_root->add_EQ(); // x=i === x-i = 0 map_xeq.update_coef(x1,1); map_xeq.update_coef(t1,-1); EQ_Handle map_yeq = map_root->add_EQ(); // y=t === y-t = 0 map_yeq.update_coef(y1,1); map_yeq.update_coef(i1,-1); mmtest.mapping = map; mmtest.var = "a"; cout << "Memory Map:\t"; map.print_with_subs(stdout); MMap mmtest2; Relation map2(2,1); // making it output 2 vars map2.name_input_var(1, "i"); map2.name_input_var(2, "j"); t1 = map2.input_var(1); i1 = map2.input_var(2); map2.name_output_var(1, "i"); x1 = map2.output_var(1); F_And *map2_root = map2.add_and(); EQ_Handle map2_xeq = map2_root->add_EQ(); // x=i+j === x-i-j = 0 map2_xeq.update_coef(x1,1); map2_xeq.update_coef(t1,-1); map2_xeq.update_coef(i1,-1); mmtest2.mapping = map2; mmtest2.var = "b"; cout << "Memory Map 2:\t"; map2.print_with_subs(stdout); #if 0 // NO LONGER IMPLEMENTED Tuple<MMap> tests; tests.append(mmtest); tests.append(mmtest2); cout << list(tests,"0"); #endif cout << MMGenerateCode(R,S,norm,0); // CG_funkyStringBuilder x; // MMGenerateCode(&x, R, S, norm, 0)->Dump(); /* Example of output function: for i=2 to N a[i] = a[i-1] + 2 IS : 2 <= i <= N MMap : "a", [i]->[i] Reads : 0, [i]->[i+1] Stmt : "w = r1 + 2" */ Relation IS2(1); IS2.name_set_var(1, "i"); IS_n = IS2.get_local(&n); IS_i = IS2.set_var(1); F_And *IS2_root = IS2.add_and(); imin = IS2_root->add_GEQ(); imin.update_coef(IS_i, 1); imin.update_const(-2); imax = IS2_root->add_GEQ(); imax.update_coef(IS_n,1); imax.update_coef(IS_i, -1); cout << "IS:\t\t"; IS2.print_with_subs(stdout); MMap mmtest3; Relation map3(1,1); // making it output 2 vars map3.name_input_var(1, "i"); i1 = map3.input_var(1); map3.name_output_var(1, "i"); x1 = map3.output_var(1); F_And *map3_root = map3.add_and(); EQ_Handle map3_xeq = map3_root->add_EQ(); // x=i === x-i = 0 map3_xeq.update_coef(x1,1); map3_xeq.update_coef(t1,-1); mmtest3.mapping = map3; mmtest3.var = "a"; cout << "Memory Map 3:\t"; map3.print_with_subs(stdout); PartialRead readTest; Relation df(1,1); df.name_input_var(1, "i"); i1 = df.input_var(1); x1 = df.output_var(1); F_And *df_root = df.add_and(); EQ_Handle df_eq = df_root->add_EQ(); df_eq.update_coef(x1,1); df_eq.update_coef(i1,-1); df_eq.update_const(-1); readTest.from = 1; readTest.dataFlow = df; Read oneReadTest; oneReadTest.partials.append(readTest); Tuple<Read> readTuple; readTuple.append(oneReadTest); cout << "Data Flow:\t"; df.print_with_subs(stdout); String stmtTest = "w = r1 + 2"; stm_info testing; testing.IS = IS2; testing.map = mmtest3; testing.read = readTuple; testing.stm = stmtTest; Tuple<stm_info> example; example.append(testing); cout << output(example); } // Main