使用 Hashtable 我想将多个对象映射到同一个键。例如。键是“年龄”,值是结构“学生”的对象。
我想在感知上会有一种链表,其中 Key 充当“头部” 25->obj1->obj2->obj3
这是我的问题:
Is the above representation correct? If not, which data structure can be used for achieving the same?
Can I look up for a specific field on the above data representation. e.g. One I reach the key 25, I look for the name 'Scott' in the row. Will I be able to stop/ get a pointer to the object containing the field Scott?
谢谢!
最佳答案
如果您使用的是 C#,最好的选择可能是(本质上,这就是您所提议的):
var collection = new Dictionary<Age, List<Student>>();
假设 Age 和 Student 都是类型。
关于c# - C#中哈希表的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3441503/