如何在C ++中使用“new”动态分配向量数组?

时间:2015-05-01 03:06:39

标签: c++ hashmap hashtable

这是一个哈希表实验室,所以我需要能够向向量添加条目。另外,我如何使用这种格式访问条目?

1 个答案:

答案 0 :(得分:2)

您可以动态分配其他任何内容的数组:

CountDownLatch latch = new CountDownLatch(1);
Observable<String> data = Observable.just("one", "two", "three", "four", "five");
Observable.zip(data, Observable.interval(1, TimeUnit.SECONDS), (d, t) -> {
    return d + " " + t;
}).finallyDo(latch::countDown).forEach(System.out::println);

latch.await(10, TimeUnit.SECONDS);

虽然使用std::vector<T>* array = new std::vector<T>[42]; 代替vector更简单:

vector
相关问题