<pedrocorreia.net ⁄>
 

<Navigables: The new features in Java 6 SE ⁄ >




clicks: 634 634 2006-10-16 2006-10-16 goto programacao myNews programacao  Bookmark This Bookmark This


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




Subscribe News RSS  Subscribe News Updates by E-mail





myNews <myNews show="rand" cat="programacao" ⁄>

A Collection of Examples of 64-bit Errors in Real Programs

Our company OOO "Program Verification Systems" develops a special static analyzer Viva64 that detect (...)

clicks: 22 22 2010-09-03 2010-09-03 goto url (new window) gamedev.net/ref... goto myNews programacao


Don't Rely on Environment.ProcessorCount

One of the most hidden knowledge in multithreaded programming is the question "How many threads I sh (...)

clicks: 53 53 2010-09-02 2010-09-02 goto url (new window) blog.liranchen.... goto myNews programacao


A Guide to Writing Games with QML

My last post on QML had a lot of people asking for an example, as opposed to a general discourse. In (...)

clicks: 53 53 2010-08-31 2010-08-31 goto url (new window) labs.trolltech.... goto myNews programacao


Ajax Best Practices: Reduce and Aggregate similar XHR calls

My mobile contract is expiring soon, so I went online and checked the different mobile companies for (...)

clicks: 43 43 2010-08-31 2010-08-31 goto url (new window) blog.dynatrace.... goto myNews programacao


Why jQuery needs JavaScriptMVC

More than a year and a half ago, I begged the jQuery community to start taking seriously the challen (...)

clicks: 55 55 2010-08-30 2010-08-30 goto url (new window) jupiterjs.com/n... goto myNews programacao


Beginning PHP: 6 Must-See Sites, Programs and Articles For New Developers

These days there's a wealth of information online for anyone wishing to learn a new programming lang (...)

clicks: 72 72 2010-08-29 2010-08-29 goto url (new window) divisionbyzero.... goto myNews programacao


The Ultimate Roundup of 55+ CSS3 Tutorials

CSS3 is something that will take web development into the next level, while modernizing the web and (...)

clicks: 50 50 2010-08-29 2010-08-29 goto url (new window) 1stwebdesigner.... goto myNews programacao


Creating in less than 30 min Flash 10.1 mobile content for Android 2.2

This afternoon I had 2 hours free to test out my new brand Google Nexus One, first step was to updat (...)

clicks: 59 59 2010-08-28 2010-08-28 goto url (new window) flashflex.com/c... goto myNews programacao