Data structures that can map a range of keys to a value

后端 未结 7 2006
死守一世寂寞
死守一世寂寞 2020-11-27 18:02

I am trying to find a data structure that takes in a particular value from a range of values and map it to a key.

For example, I have the following conditions:

7条回答
  •  情深已故
    2020-11-27 18:30

    just have an List as a value in your Map.

    Map> map = new HashMap>();
    

    and also one Suggustion:

    do not use Hashtable unless you want synchronized access.

    EDIT:

    Hashtable methods are synchronized, i.e., no two threads can access those methods at a single point of time. HashMap menthods are not Synchronized. If you use Hashtable there will be a performance hit. use HashMap for better performance.

提交回复
热议问题