Efficient data structure for fast random access, search, insertion and deletion

前端 未结 8 2120
灰色年华
灰色年华 2021-01-31 11:11

I\'m looking for a data structure (or structures) that would allow me keep me an ordered list of integers, no duplicates, with indexes and values in the same range.

I ne

8条回答
  •  悲&欢浪女
    2021-01-31 11:48

    I don't know what language you're using, but if it's Java you can leverage LinkedHashMap or a similar Collection. It's got all of the benefits of a List and a Map, provides constant time for most operations, and has the memory footprint of an elephant. :)

    If you're not using Java, the idea of a LinkedHashMap is probably still suitable for a usable data structure for your problem.

提交回复
热议问题