map的一种替代方案,不会自动排序
2009-11-26 11:07
393 查看
看来只有用vector< std::pair<std::string, std::string> >了
...
#include <vector>
#include <string>
#include <iostream>
int main(int argc, char** argv)
{
using namespace std;
typedef pair <std::string, std::string> spair__;
typedef vector< spair__ > vector_type;
vector_type svec;
svec.push_back( spair__( "January", "2004-01" ) );
svec.push_back( spair__( "Feburary", "2004-02" ) );
svec.push_back( spair__( "March", "2004-03" ) );
svec.push_back( spair__( "April", "2004-04" ) );
svec.push_back( spair__( "May", "2004-05" ) );
for ( vector_type::iterator it = svec.begin();
it != svec.end();
++it )
cout << it->first << " " << it->second << "/n";
return 0;
}
...
#include <vector>
#include <string>
#include <iostream>
int main(int argc, char** argv)
{
using namespace std;
typedef pair <std::string, std::string> spair__;
typedef vector< spair__ > vector_type;
vector_type svec;
svec.push_back( spair__( "January", "2004-01" ) );
svec.push_back( spair__( "Feburary", "2004-02" ) );
svec.push_back( spair__( "March", "2004-03" ) );
svec.push_back( spair__( "April", "2004-04" ) );
svec.push_back( spair__( "May", "2004-05" ) );
for ( vector_type::iterator it = svec.begin();
it != svec.end();
++it )
cout << it->first << " " << it->second << "/n";
return 0;
}
相关文章推荐
- map的一种替代方案,不会自动排序
- map的一种替代方案,不会自动排序(转)
- Base: 一种Acid的替代方案
- Spark,一种款速数据分析替代方案之下篇
- 一种自动生成网络IP的方案
- .NET 中禁止map自动排序
- 基于spark排序的一种更廉价的实现方案-附基于spark的性能测试
- 基于spark排序的一种更廉价的实现方案-附基于spark的性能测试
- 关于枚举enum的tostring方法不能重写的一种替代方案
- 选择排序法 当数据量较小的时候,使用基本排序方案并不会显著影响程序性能。 选择排序是十分常用的基本排序方案之一。
- 分享一种RecyclerView滑动到底部自动加载的实现方案
- Spark,一种快速数据分析替代方案
- Spark,一种快速数据分析替代方案
- 一种解决h5页面背景音乐不能自动播放的方案
- Eclipse中Android项目R.java文件不会自动生成的一种情况的解决方式
- sql server 2005 主键自动增长的替代方案
- 一种更高效的组件自动注册方案(android组件化开发)
- 基于spark排序的一种更廉价的实现方案-附基于spark的性能测试
- 基于spark排序的一种更廉价的实现方案-附基于spark的性能测试
- 一种MemoryStream的替代方案