Java Class that implements Map and keeps insertion order?

后端 未结 9 2043
一向
一向 2020-11-22 11:28

I\'m looking for a class in java that has key-value association, but without using hashes. Here is what I\'m currently doing:

  1. Add values to a Hashtable<
9条回答
  •  不思量自难忘°
    2020-11-22 11:44

    If an immutable map fits your needs then there is a library by google called guava (see also guava questions)

    Guava provides an ImmutableMap with reliable user-specified iteration order. This ImmutableMap has O(1) performance for containsKey, get. Obviously put and remove are not supported.

    ImmutableMap objects are constructed by using either the elegant static convenience methods of() and copyOf() or a Builder object.

提交回复
热议问题