<myBlog show="last" ⁄>
<mySnippets order="rand" ⁄>
<myPhoto order="random" ⁄>
<mySnippets type="lang" ⁄>
<myQuote order="random" ⁄>
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myVisitorsMap ⁄>Suppose you have a collection of objects and you want to select a specific range of them. For example, in a collection of integers, selecting all numbers less than 1000. Your first way is of course writing a method to do this job. This method will iterate over all objects and apply the condition to them, acquiring the new collection in O(n) time. In addition to long execution time for big collections, you may have a design problem in where placing the new method. What would happen if we had such method in Collection class (or its children) and could benefit from the internal structure of that collection to reduce running-time?
What are navigables?
It seems that developers of Java in Sun have recognized this need. There are two new interfaces in Java 6 SE called NavigableMap and NavigableSet which facilitate "navigating" through collections. NavigableSet extends SortedSet and currently is implemented by TreeSet and concurrentSkipListSet (a new class in Java collection). It includes methods to return iterators in ascending and descending orders, as well as methods that return a sorted or navigable set of a special portion of data. It has also methods that return the element with the given condition. For example in a TreeSet of Doubles, to find the biggest element less than 10.5 we can write:
este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:
http://www.devx.com/Java/Article/33872/1954
<myNews show="rand" cat="programacao" ⁄>