I want to store a key,values pair that allows me to get the values by its position (ordering must persist) or by its key name. I was thinking to use HashMap but i do not want to iterate through all values to get the value by index.
I would need something like this:
MyCollection<String, Object> objects = new MyCollection<String, Object>();
objects.put ("id", Object1);
objects.put ("name", Object2);
// And now access the values by index:
Object obj1 = objects.get(1);
// or by key name:
Object obj2 = objects.getByKeyName("name");
What is the best collection to use (it must be android < 11 compatible>