Generic Key/Value pair collection in that preserves insertion order?

前端 未结 9 1248
刺人心
刺人心 2020-12-09 01:40

I\'m looking for something like a Dictionary however with a guarantee that it preserves insertion order. Since Dictionary is a hashtable, I do not think it does.<

9条回答
  •  情歌与酒
    2020-12-09 02:04

    Another option for a Generic Key/Value pair that preserves insertion is to use something like:

    Queue>
    

    This would be a guaranteed ordered list. You can en-queue and dequeue in an ordered faction similar to Add/Remove of dictionary as opposed to resizing an Array. It can often serve as a middle ground between a non-resizing ordered (by insertion) array and an autoresizing unordered (by insertion) list.

提交回复
热议问题