I was wondering if there is a class that implements Map and List interfaces in Java.
I have a data structure, which is basically a Map . I map strings (IDs) to Image s. But in a certain part of my code, I need to provide the user with all available IDed Images . The only way to do this so far is to write this:
for (String id : myMap.keySet()) {
So, it would be nice to have a class that implements both Map and List , so I could just write:
for (Image img : myMap) {
Does anyone know of such an implementation?
EDIT : after looking at the answers (which everything is correct, voted), now I understand that I will also need to sort the map. When I say βsorted,β all I have in mind is that I would like it to have values ββin a specific order that I could change. I know this is not an original question, but I just realized that I needed it.
EDIT 2 : I seem to be indecisive. I need an ordered map, not a sorted one. Sorry for the confusion, people.
java list map
Savvas Dalkitsis Jul 31 '09 at 12:11 2009-07-31 12:11
source share