overriding tailMap() method

Hello there,

This is my problem. I am working on a dictionary program using the TreeMap structure. I would like use the trailMap() method to get a subMap of higher keys and their values. But, I want to put a limit on the number of keys I am getting back. I have more than 2 thousands of entries in the TreeMap, so in theory I get 2 thousands key in the new subMap. I would like to limit it to around 30 entries.

I thought about three possible solutions: One, overriding the tailMap. I prefer to take that approach. However, I could not found the original implementation code. Can someone direct me to the actual code that produce tailMap (in Set, or Map)?

Second and third options, are to write my own tailMap method from start, or limit the capacity of the new SortedMap (getting from tailMap). Writing my own seems like the second best thing to do. I am not sure limiting the capacity, it seems waste of resources.

His someone has a good idea on which approach I should take?

[1011 byte] By [ebroCasea] at [2007-11-27 11:04:05]
# 1

The tailmap is just a view of the original map so there's no extra memory being used. Just stop your traversal of the tailmap after 30 entries or whatever you want.

ejpa at 2007-7-29 12:55:40 > top of Java-index,Core,Core APIs...
# 2

Thank you, this are good news.

ebroCasea at 2007-7-29 12:55:40 > top of Java-index,Core,Core APIs...
# 3

It says that in the Javadoc. Didn't you see it?

ejpa at 2007-7-29 12:55:40 > top of Java-index,Core,Core APIs...