{ by david linsin }

March 02, 2007

Navigable Interfaces

I stumbled across this article on DevX.com about Navigable Interfaces, a new API in Java 6. It allows you to do some cool stuff like retrieving a range of entries in a TreeMap based on their keys:

TreeMap<Long, String> map = new TreeMap<Long, String>();
map.subMap(564566L, 564600L);

In the sample code above, map.subMap() retrieves a NavigableMap containing all values with keys between 564566 and 564599.

According to the article, the new API has some limitation. For instance it's not possible, at least as simple as the sample above, to retrieve a NavigableMap based on entry values.



  • mail(dlinsin@gmail.com)
  • jabber(dlinsin@gmail.com)
  • skype(dlinsin)