小编Bog*_*dan的帖子

结合字符串向量

我一直在阅读Accelerated C++,我不得不说这是一本有趣的书.

在第6章中,我必须使用<algorithm>中的函数将vector <string>连接成单个字符串.我可以使用累积,但它没有帮助,因为字符串容器只能push_back字符.

int main () {
  using namespace std;
  string str = "Hello, world!";
  vector<string>  vec (10, str);
  // Concatenate here?

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

如何将字符串连接在一起?

c++ string stl vector

21
推荐指数
4
解决办法
2万
查看次数

6
推荐指数
1
解决办法
3799
查看次数

合并散列删除算法

有人可以向我展示一个合并链式哈希表的删除算法示例吗?

我的插入算法是这样的:

Insert (key) 
    int p = hash(key)
    if d[p] = NIL then
        d[p] = key
        next[p] = NIL
    else
        while next[p] != NIL 
            p = next[p]
        endwhile
        td[firstEmpty] = key
        next[p] = firstEmpty
        next[firstEmpty] = NIL
    endif
    UpdateFirstEmpty(); //sets firstEmpty to first empty slot with lowest index
endInsert
Run Code Online (Sandbox Code Playgroud)

假设表中的槽数为 13。散列函数返回Key%13

    Keys | 5 | 18 | 16 | 15 | 13 | 31 | 26 |      
Hash(key)| 5 |  5 |  3 |  2 |  0 | …
Run Code Online (Sandbox Code Playgroud)

algorithm hash pseudocode

6
推荐指数
1
解决办法
2503
查看次数

我的名单上发生了什么?

为什么

List<Object> objectList; = some objects

List<Object> getList() 
{
  return objectList; //or return new List<Object>(objectList);
}
Run Code Online (Sandbox Code Playgroud)

返回一个列表,其中包含所有引用原始列表项目的项目?

谢谢.

c# list

0
推荐指数
1
解决办法
147
查看次数

标签 统计

algorithm ×1

c# ×1

c++ ×1

hash ×1

list ×1

pseudocode ×1

stl ×1

string ×1

vector ×1

visual-studio-2010 ×1