I was wandering if there is a class out there that implements both Map and List interfaces in Java.
I have a data structure that is primarily a Map. I map strings (IDs) to Images. But in a specific part of my code i need to present the user with all the available IDed Images. The only way to do that so far is to write this :
for (String id : myMap.keySet()) {
// get the image like this "myMap.get(id)"
}
so it would be nice to have a class that implements both Map and List so i could simply write :
for (Image img : myMap) {
// the image is img
}
Does anyone know of such an implementation?
EDIT: after viewing the answers (which are all correct, voted up) i now realize i would also need the map to be sorted. When i say sorted all i mean is that i would like it to have the values in a specific order, one that i would be able to modify. I know this is not the original question but i just realized that i need that.
EDIT 2: It seems i am indecisive. What i need is an ordered map not a sorted one. sorry for the confusion people.