Dictionary best data structure for train routes?

后端 未结 6 1184
北海茫月
北海茫月 2020-12-02 01:08

So I\'ve been tasked with essentially reading in a file (notepad file) that has a bunch of train stops and the time it takes to get from one stop to another. For example it

6条回答
  •  旧时难觅i
    2020-12-02 01:34

    A dictionary could be good for this, yes. But if you need to keep track of what stop comes next to the other, you might need something else, like an ordered dict, or a small class for a Stop that defines the next one (and whatever other data you'd like to keep about the stop), or even a list of stops, as it keeps the order.

    Depending on what kind of access you need or what you want to do with this data, any of these could work for you.

    Good luck.

提交回复
热议问题