正如标题所说,我有一组hashsets,但我不知道如何将它们应用于比较器.像这样:
//This Works:
public HashSet<Animal.AnimalCell>UpdateList = new HashSet<Animal.AnimalCell>(new CellComparer());
//This Does not work:
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>(new CellComparer())[10];
//This Does not Work :
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>[10](new CellComparer());
//This Works:
public HashSet<Animal.AnimalCell>[]UpdateListThreaded = new HashSet<Animal.AnimalCell>[10];
Run Code Online (Sandbox Code Playgroud)
当然我需要比较器..我做错了什么?谢谢
我想实现一个快速随机生成器,我遇到了这个网站:https://en.wikipedia.org/wiki/Xorshift,其中提出以下代码
#include <stdint.h>
/* The state must be seeded so that it is not everywhere zero. */
uint64_t s[2];
uint64_t xorshift128plus(void) {
uint64_t x = s[0];
uint64_t const y = s[1];
s[0] = y;
x ^= x << 23; // a
s[1] = x ^ y ^ (x >> 17) ^ (y >> 26); // b, c
return s[1] + y;
}
Run Code Online (Sandbox Code Playgroud)
我想知道这里的const是否有用,我可以安全地删除吗?