Ivan Jozsef Balazs wrote:There is a Script called the API Docs.
Class TreeMap
It is a valuable source of information, many contemplations stem from there, it spreads ideas and yields guidance even about style.
public SortedMap<K,V> subMap(K fromKey,
K toKey)
/*
Returns a view of the portion of this map
whose keys range from fromKey, inclusive,
to toKey, exclusive. (If fromKey and toKey
are equal, the returned map is empty.) The
returned map is backed by this map,
so changes in the returned map are reflected
in this map, and vice-versa. The returned map
supports all optional map operations that this map supports.
The returned map will throw an IllegalArgumentException
on an attempt to insert a key outside its range.
*/
But all this is based on key, and for the first search, we need name as the key. submap would have been better applciable if I was looking for an age group but not age of any particular name.
I thought of creating a custom object with name and age, but the issue is that, without the name, I can not find the age group as the custom object would be incomplete for the equals to work.
As I had specified earlier
But all operations are using key only.
filtering value is what I think might be required here.