由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 谁能给个hashset实现的例子么?
相关主题
1道brianbench 的题 c++M面完焦急等待中。。。。。大家看看我是个什么水平?
leetcode上wild match请教一个字符串比较排序的问题 (转载)
wordbreak in C?问到算法题和一道c++题
问一个有关c++ strcmp的问题H1B 概率最低事多少(对于adv degree)
一道面试题昨天面试MS
贡献一道电面题这道题好像有点难
攒个人品,发个google电话面试题问一下prefix tree (trie) 的题目
Facebook phone screen请假大家一道BB的题
相关话题的讨论汇总
话题: const话题: set话题: char话题: hash话题: eqstr
进入JobHunting版参与讨论
1 (共1页)
f********3
发帖数: 210
1
比如面试时,用set显然更好写。但hashset快。
hashset不是STL里面的,那么是不是所有的函数都得自己写。。。。感觉太麻烦了。。。
在这里看到个例子。那么面试时是不是还得这样写?
有没有好点的hashset的例子?多谢了
struct eqstr
{
bool operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) == 0;
}
};
void lookup(const hash_set, eqstr>& Set,
const char* word)
{
hash_set, eqstr>::const_iterator it
= Set.find(word);
cout << word << ": "
<< (it != Set.end() ? "present" : "not present")
<< endl;
}
int main()
{
hash_set, eqstr> Set;
Set.insert("kiwi");
Set.insert("plum");
Set.insert("apple");
Set.insert("mango");
Set.insert("apricot");
Set.insert("banana");
lookup(Set, "mango");
lookup(Set, "apple");
lookup(Set, "durian");
}
S**I
发帖数: 15689
2
boost library

。。

【在 f********3 的大作中提到】
: 比如面试时,用set显然更好写。但hashset快。
: hashset不是STL里面的,那么是不是所有的函数都得自己写。。。。感觉太麻烦了。。。
: 在这里看到个例子。那么面试时是不是还得这样写?
: 有没有好点的hashset的例子?多谢了
: struct eqstr
: {
: bool operator()(const char* s1, const char* s2) const
: {
: return strcmp(s1, s2) == 0;
: }

1 (共1页)
进入JobHunting版参与讨论
相关主题
请假大家一道BB的题一道面试题
请教一道G题的代码量贡献一道电面题
一道Google面试题,怎么做?(题目描述有误,已修改)攒个人品,发个google电话面试题
word ladder 时间空间复杂度是多少, bfs 解的Facebook phone screen
1道brianbench 的题 c++M面完焦急等待中。。。。。大家看看我是个什么水平?
leetcode上wild match请教一个字符串比较排序的问题 (转载)
wordbreak in C?问到算法题和一道c++题
问一个有关c++ strcmp的问题H1B 概率最低事多少(对于adv degree)
相关话题的讨论汇总
话题: const话题: set话题: char话题: hash话题: eqstr