Congrats on your first post!
First, a word of advice - this isn't so much an Android issue as it is a Java issue, so while tagging this question with Android may gain it more visibility, it's a bit of a mislabelling.
Second, if you are tagging Java, you can also try to tag the particular Java version (Java 6/7/8 etc) which should be found in your build.gradle
file...
Third, please make sure you are searching, and making sure that you are reviewing SO's suggested similar questions, as most items, such as this one, have been asked & answered before...
As for your question, there isn't a single instance of the Map class tree that has indexable methods. See https://docs.oracle.com/javase/7/docs/api/java/util/Map.html and it's descendants... also https://docs.oracle.com/javase/tutorial/collections/interfaces/map.html.
However, the Apache Commons library has an implementation of a LinkedMap that does have a indexOf()
method... though that may be heavyweight to add for such a use case?
There are ways to do this by yourself however, mainly which involve forcing that by wrapping/unwrapping into other data structures, and they tend to be inefficient (O(n)
)...
Here are some posts about this:
As you can see, performance and verbosity are both potential issues here...
I guess the best thing would be to push back and see if you can clarify the use-case here, so that we can help determine what problem you are trying to solve exactly...