小编Yan*_*ann的帖子

C#中带有比较器的HashSet数组

正如标题所说,我有一组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)

当然我需要比较器..我做错了什么?谢谢

c# arrays hashset icomparer

5
推荐指数
1
解决办法
778
查看次数

c ++ const使用.我可以删除吗?

我想实现一个快速随机生成器,我遇到了这个网站: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是否有用,我可以安全地删除吗?

c++ const

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

标签 统计

arrays ×1

c# ×1

c++ ×1

const ×1

hashset ×1

icomparer ×1