相关疑难解决方法(0)

c#中的多键字典?

我知道BCL中没有一个,但有人能指出我一个好的开源吗?

By Multi我指的是2把钥匙.;-)

c# dictionary

112
推荐指数
10
解决办法
15万
查看次数

C#中的多键词典(另一种)?

基于这个问题,是否有一个简单的解决方案,可以使用多键字典,其中任何一个键都可以用来识别值?

即.

MultikeyDictionary<TKey1, TKey2, TValue> foo;
foo.Add(key1, key2, value);
myValue = foo[key1];
// value == myValue
foo.Remove(key2);
myValue = foo[key1]; // invalid, Exception or null returned
Run Code Online (Sandbox Code Playgroud)

c# data-structures

9
推荐指数
1
解决办法
1万
查看次数

Map <K1,K2,V>的任何实现,即两个键?

我需要一张有两个键的地图,例如

Map2<String /*ssn*/, String /*empId*/, Employee> _employees;
Run Code Online (Sandbox Code Playgroud)

这样我就可以

_employees.put(e.ssn(), e.empId(), e)
Run Code Online (Sandbox Code Playgroud)

然后

_employees.get1(someSsn);
_employees.get2(someImpId);
Run Code Online (Sandbox Code Playgroud)

甚至

_employees.remove1(someImpId);
Run Code Online (Sandbox Code Playgroud)

我不知道为什么我要停在两个,为什么不多,可能是因为我现在需要的情况是这样:-)但是类型需要处理固定数量的键是类型安全的 - 类型参数不能是vararg :-)

感谢任何指针,或建议为什么这是一个坏主意.

java generics maps

7
推荐指数
1
解决办法
4047
查看次数

标签 统计

c# ×2

data-structures ×1

dictionary ×1

generics ×1

java ×1

maps ×1