g++上的无序映射
Unordered Maps on g++
我目前正在学习STL,并试图为字典文件实现一个无序映射。
这是我第一次这样做,所以在尝试之前我做了很多研究。
我想为我的作业做一个无序的地图,因为如果我们能让我们的项目比教授目前的解决方案更快,我们就能获得额外的分数
我遇到的问题是,我一直得到这个错误:
SpellCheck.h:16:错误:ISO C++禁止在没有类型的情况下声明"无序映射"
我确信我的语法是正确的,但我可能遗漏了一些东西。
我不确定这是否有帮助,但我正在学校服务器上使用g++进行编译。
我的g++版本是g++(GCC)4.4.7.
#ifndef SPELLCHECK_H
#define SPELLCHECK_H
#include <vector>
#include <tr1/unordered_map>
#include <string>
using std::vector;
using std::string;
class SpellCheck
{
private:
typedef vector<string> Vector;
typedef unordered_map<string, int> Dictionary;
};
#endif
这也应该有效。使用-std=c++0x
标志编译,以使用带有g++的c++11。
#ifndef SPELLCHECK_H
#define SPELLCHECK_H
#include <vector>
#include <unordered_map>
#include <string>
class SpellCheck
{
private:
typedef std::vector<std::string> Vector;
typedef std::unordered_map<std::string, int> Dictionary;
};
#endif
相关文章:
- 递归无序映射
- 正在将无序映射设置为无序映射的值
- 智能指针作为无序映射键,并通过引用进行比较
- 打印无序映射的第二个元素,即集合
- 由并发无序映射查找线程调用的函数是否安全?
- 如何按值对无序哈希映射进行排序
- 将大数字(10-12 位数字)存储在无序映射中<字符串,整数>
- 使用无序映射在STL中存储键值对
- 为C++中的无序映射获取给定输入键的错误值
- 将大型对象存储在无序映射中是否效率低下
- 在无序映射的结构化绑定中推导类型
- 使用无序映射进行错误索引
- 将一个向量对放在一个无序映射与一个映射中
- 如何在c++中修改无序映射中的每个值
- C++:使用一对(cpp_int,int)整数作为无序映射中的键(其中cpp_int是boost多精度整数)
- 将 [] 索引到无序映射时出现段错误
- 以std::字符串作为关键字,按字典顺序对一个无序映射进行排序
- 无序映射存储桶的节点大小
- 在无序映射<字符串上使用 find(),向量<string>>与 C++ 中的有序映射花费相同的时间
- 以三个无符号字符为关键字的无序映射