问题描述:

In my program (a program that assists with pathfinding), i need to store a list that contains entries consisting of a start node and an end node. A dictionary won't work as i cannot guarantee that the "key" (a node of course) will be unique. What is the best way to store this manner of data?

Edit: i use C# and .Net 3.5.

网友答案:

You might be better off simply using an array of structs. Or a vector of structs. This allows for non-unique nodes in your list. Vectors are a standard template in C++, but if C# doesn't support it, then an array should work fine.

网友答案:

Would it be possible for you to use a List of KeyValuePair objects? Like this?

List<KeyValuePair<ObjectA, ObjectB>> list = new List<KeyValuePair<ObjectA, ObjectB>>();

I don't have VS in front of me right now, so I'm not sure if I have the syntax 100% right, but hopefully this helps.

网友答案:

If your language of choice supports sets, a set of (start, end) tuples is what you might be looking for.

相关阅读:
Top