IvanVdc
IvanVdc

Reputation: 1

ConcurrentSkipListMap put in order

I have a ConcurrentSkipListMap of keys and values. It is very important to hold the order of the keys.

The problem appears when I try to insert a new value in a particular position. The only one method to insert a value is the put() that put this value in the last position.

With the replace method it can only edit the value, not the key.

Is it possible? What can I do? Can you tell me another class to do it?

Upvotes: 0

Views: 834

Answers (1)

Zielu
Zielu

Reputation: 8552

The ConcurrentSkipListMap holds the order of the keys on its own as they are sorted.

So either you were not aware of it or you actually do not want to hold order of the keys but manipulate them yourself.

If you meant that you want the keys returned in the order in which they were put into the map than use the separet List (ConcurrentQueue if you need concurrency) and place the keys there manually.

Upvotes: 2

Related Questions