int main(){
    
    std::cout << std::endl;
    
    {
      std::array<int,SIZE/1000> myArray;
      measurePerformance(myArray,"std::array<int,SIZE/1000>");   
    }
    
    {
      std::vector<int> myVec(SIZE);
      measurePerformance(myVec,"std::vector<int>(SIZE)");
    }

    {
      std::deque<int>myDec(SIZE);
      measurePerformance(myDec,"std::deque<int>(SIZE)");
    }
    
    {
      std::list<int>myList(SIZE);
      measurePerformance(myList,"std::list<int>(SIZE)");
    }
    
    {
      std::forward_list<int>myForwardList(SIZE);
      measurePerformance(myForwardList,"std::forward_list<int>(SIZE)");
    } 
       
    {
      std::string myString(SIZE,' ');
      measurePerformance(myString,"std::string(SIZE,' ')");
    }
    
    std::vector<int> tmpVec(SIZE);
    std::iota(tmpVec.begin(),tmpVec.end(),0);
    
    {
      std::set<int>mySet(tmpVec.begin(),tmpVec.end());
      measurePerformance(mySet,"std::set<int>");
    }
    
    {
      std::unordered_set<int>myUnorderedSet(tmpVec.begin(),tmpVec.end());
      measurePerformance(myUnorderedSet,"std::unordered_set<int>");
    }
    
    {
      std::map<int,int>myMap;
      for (auto i= 0; i <= SIZE; ++i) myMap[i]= i;
      measurePerformance(myMap,"std::map<int,int>");
    }
    
    {
      std::unordered_map<int,int>myUnorderedMap;
      for (auto i= 0; i <= SIZE; ++i) myUnorderedMap[i]= i;
      measurePerformance(myUnorderedMap,"std::unordered_map<int,int>");
    }  
    
}
示例#2
0
static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSetting, DBVARIANT* id, const TCHAR* pszUserID, TCHAR *nick, TCHAR *group)
{
    MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
    if (CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)szProto) != 0) {
        CallService(MS_DB_CONTACT_DELETE, hContact, 0);
        AddMessage(LPGENT("Failed to add %S contact %s"), szProto, pszUserID);
        return INVALID_CONTACT_ID;
    }

    mySet(hContact, szProto, pszUniqueSetting, id);

    CreateGroup(group, (MCONTACT)hContact);

    if (nick && *nick) {
        db_set_ws((MCONTACT)hContact, "CList", "MyHandle", nick);
        AddMessage(LPGENT("Added %S contact %s, '%s'"), szProto, pszUserID, nick);
    }
    else AddMessage(LPGENT("Added %S contact %s"), szProto, pszUserID);

    srcDb->FreeVariant(id);
    return hContact;
}
示例#3
0
int main(int argc, char **argv)
{
    QApplication application(argc,argv);

    DGtal::Viewer3D viewer;

    DGtal::Z3i::Point center(0,0,0);
    DGtal::ImplicitRoundedHyperCube<Z3i::Space> myCube( center, 20, 2.8);
    DGtal::Z3i::Domain domain(myCube.getLowerBound(),
                              myCube.getUpperBound());

    DGtal::Z3i::DigitalSet mySet(domain);

    DGtal::Shapes<DGtal::Z3i::Domain>::euclideanShaper( mySet, myCube);


    viewer.show();
    // viewer << mySet << DGtal::Display3D::updateDisplay;


    //! [ImageSetDT-DT]
    typedef DGtal::SetPredicate<DGtal::Z3i::DigitalSet> Predicate;
    Predicate aPredicate(mySet);

    typedef DGtal::DistanceTransformation<Z3i::Space, Predicate, 2> DTL2;
    typedef DTL2::OutputImage OutputImage;
    DTL2 dt(domain,aPredicate);

    OutputImage result = dt.compute();
    //! [ImageSetDT-DT]

    OutputImage::Value maxDT = (*std::max_element(result.begin(),
                                result.end()));


    GradientColorMap<OutputImage::Value> gradient( 0, maxDT);
    gradient.addColor(DGtal::Color::Blue);
    gradient.addColor(DGtal::Color::Green);
    gradient.addColor(DGtal::Color::Yellow);
    gradient.addColor(DGtal::Color::Red);


    for(Z3i::Domain::ConstIterator it = domain.begin(),
            itend = domain.end(); it != itend;
            ++it)
        if (result(*it) != 0)
        {
            OutputImage::Value  val= result( *it );
            DGtal::Color c= gradient(val);

            viewer <<  DGtal::CustomColors3D(c,c) << *it    ;

        }


    viewer << DGtal::ClippingPlane(1,0,0,0);
    //@todo updateDisplay is in Display3D or Viewer3D (cf doc)?
    viewer << DGtal::Display3D::updateDisplay;

    return application.exec();


}
示例#4
0
void CUdmApp::UdmMain(
					 Udm::DataNetwork* p_backend,		// Backend pointer(already open!)
					 Udm::Object focusObject,			// Focus object
					 set<Udm::Object> selectedObjects,	// Selected objects
					 long param)						// Parameters
{	
	try
    {
		std::string outputPath;
		std::string message = "Please specify the Output Directory";
		Utils::getPath (message, outputPath);
				
		// Do not do anything if Cancel button is pressed
		if (outputPath.size () == 0)
			return;

		bool valid_interpretation = 0;

		if (focusObject != Udm::null ||
			! selectedObjects.empty())
        {
			std::set<Udm::Object> mySet (selectedObjects);
			if (focusObject != Udm::null)
				mySet.insert (focusObject);

			for (std::set<Udm::Object>::iterator iter = mySet.begin();
			iter != mySet.end();
			++iter)
            {
				// Interpretation should start from Benchmarking Aspect
				Udm::Object root = *iter;
				std::string kindName = (*iter).type().name();
				
				// Generate MPC file only for the Component
				if (kindName == "BenchmarkAnalysis")
				{
					BGML_Visitor visitor (outputPath);
					SetUpVisitor (BenchmarkAnalysis, root, visitor);
					valid_interpretation = 1;
				}
			}
		}

		if (! valid_interpretation)
		{
			Udm::Object root_obj = p_backend->GetRootObject();
			PICML::RootFolder root_folder = PICML::RootFolder::Cast (root_obj);
			std::set<PICML::ComponentAnalyses> child_benchmarks =
				root_folder.ComponentAnalyses_children ();
			for (std::set<PICML::ComponentAnalyses>::iterator iter = child_benchmarks.begin ();
			iter != child_benchmarks.end ();
			iter ++)
			{
				std::set<PICML::BenchmarkAnalysis> benchmarks =
					iter->BenchmarkAnalysis_children();
				for (std::set<PICML::BenchmarkAnalysis>::iterator iter2 = benchmarks.begin ();
				iter2 != benchmarks.end ();
				iter2 ++)
				{
					Udm::Object root = *iter2;
					if (root != Udm::null)
					{
						BGML_Visitor visitor (outputPath);
						SetUpVisitor (BenchmarkAnalysis, root, visitor);
						valid_interpretation = 1;
					}
				}
				
			}
		}

		if (valid_interpretation)		
			AfxMessageBox ("Bencharking files successfully generated");
		else
			showUsage ();
	 }
      catch(udm_exception &ex)
        {
          AfxMessageBox ("Error: generation of Benchmarking files failed");
		  AfxMessageBox (ex.what());
          return;
        }
}
示例#5
0
static MCONTACT ImportContact(MCONTACT hSrc)
{
    MCONTACT hDst;
    TCHAR id[ 40 ], *pszUniqueID;
    char  szProto[100];

    // Check what protocol this contact belongs to
    if (myGetS(hSrc, "Protocol", "p", szProto)) {
        AddMessage(LPGENT("Skipping contact with no protocol"));
        return NULL;
    }

    if (!IsProtocolLoaded(szProto)) {
        AddMessage(LPGENT("Skipping contact, %S not installed."), szProto);
        return NULL;
    }

    // Skip protocols with no unique id setting (some non IM protocols return NULL)
    char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
    if (!pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND) {
        AddMessage(LPGENT("Skipping non-IM contact (%S)"), szProto);
        return NULL;
    }

    DBVARIANT dbv;
    if (myGet(hSrc, szProto, pszUniqueSetting, &dbv)) {
        AddMessage(LPGENT("Skipping %S contact, ID not found"), szProto);
        return NULL;
    }

    // Does the contact already exist?
    switch (dbv.type) {
    case DBVT_DWORD:
        pszUniqueID = _ltot(dbv.dVal, id, 10);
        hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
        break;

    case DBVT_ASCIIZ:
        pszUniqueID = NEWTSTR_ALLOCA(_A2T(dbv.pszVal));
        hDst = HContactFromID(szProto, pszUniqueSetting, pszUniqueID);
        break;

    case DBVT_WCHAR:
        pszUniqueID = NEWTSTR_ALLOCA(dbv.ptszVal);
        hDst = HContactFromID(szProto, pszUniqueSetting, pszUniqueID);
        break;
    }

    if (hDst != INVALID_CONTACT_ID) {
        AddMessage(LPGENT("Skipping duplicate %S contact %s"), szProto, pszUniqueID);
        srcDb->FreeVariant(&dbv);
        return NULL;
    }

    TCHAR *tszGroup = myGetWs(hSrc, "CList", "Group"), *tszNick = myGetWs(hSrc, "CList", "MyHandle");
    if (tszNick == NULL)
        tszNick = myGetWs(hSrc, szProto, "Nick");

    hDst = AddContact(hdlgProgress, szProto, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup);
    mir_free(tszGroup), mir_free(tszNick);

    if (hDst != INVALID_CONTACT_ID) {
        // Hidden?
        if (!myGet(hSrc, "CList", "Hidden", &dbv)) {
            mySet(hDst, "CList", "Hidden", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Ignore settings
        if (!myGet(hSrc, "Ignore", "Mask1", &dbv)) {
            mySet(hDst, "Ignore", "Mask1", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Apparent mode
        if (!myGet(hSrc, szProto, "ApparentMode", &dbv)) {
            mySet(hDst, szProto, "ApparentMode", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Nick
        if (!myGet(hSrc, szProto, "Nick", &dbv)) {
            mySet(hDst, szProto, "Nick", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Myhandle
        if (!myGet(hSrc, szProto, "MyHandle", &dbv)) {
            mySet(hDst, szProto, "MyHandle", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // First name
        if (!myGet(hSrc, szProto, "FirstName", &dbv)) {
            mySet(hDst, szProto, "FirstName", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Last name
        if (!myGet(hSrc, szProto, "LastName", &dbv)) {
            mySet(hDst, szProto, "LastName", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // About
        if (!myGet(hSrc, szProto, "About", &dbv)) {
            mySet(hDst, szProto, "About", &dbv);
            srcDb->FreeVariant(&dbv);
        }
    }
    else AddMessage(LPGENT("Unknown error while adding %S contact %s"), szProto, pszUniqueID);

    return hDst;
}