zoukankan      html  css  js  c++  java
  • map映射类

     

    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <map>
    using namespace std;

    class MapTemplate
    {
    public:
    typedef map <int ,string> templatemap;
    templatemap testmap;

    templatemap::iterator Find(int nID)
    {
     return testmap.find(nID);
    }

    string GetElement(int nID)
    {
     templatemap::iterator iter = Find(nID);
     if(iter == testmap.end())
      return NULL;
     else
     return iter->second;
    }
    };

    void main()
    {
        MapTemplate *pmap=new  MapTemplate();   
     string data2="getid()";
     string data1="gethp()";
     string data="getmp()";
     pmap->testmap[1]=data;
     pmap->testmap[2]=data1;
     pmap->testmap[3]=data2;
     for (MapTemplate::templatemap::iterator iter = pmap->testmap.begin();iter != pmap->testmap.end(); iter++)
     {
      cout<<iter->first<<" ";
      string data2=iter->second;
      for(int i=0;i<strlen(data2.c_str());i++)
         {
             cout<<data2[i];
         }
      cout<<endl;
     }
     if(pmap->Find(3)==pmap->testmap.end())
      return;
      string data4=pmap->GetElement(3);
      cout<<3<<" ";
      for(int i=0;i<strlen(data4.c_str());i++)
      {
             cout<<data4[i];
      }
         getchar();
    }

  • 相关阅读:
    文件的上传
    JSP基础知识
    AJAX
    Listener
    Filter(一)
    session
    网络爬虫(9)-xpath解析
    网络爬虫(8)-正则表达式
    网络爬虫(7)-beautifulSoup解析库
    网络爬虫(6)-Requests库
  • 原文地址:https://www.cnblogs.com/byfei/p/3112314.html
Copyright © 2011-2022 走看看