<pedrocorreia.net ⁄>
 

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




clicks: 549 549 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" ⁄>

Ajax for Java developers

Ajax applications driven by asynchronous server-side events can be tricky to imp (...)

clicks: 444 444 2007-07-19 2007-07-19 goto url (new window) ibm.com/develop... goto myNews programacao


Easy Display Switch with CSS and jQuery

Today, I would like to go over a quick and simple way to allow your users to swi (...)

clicks: 423 423 2009-03-14 2009-03-14 goto url (new window) designm.ag/tuto... goto myNews programacao


An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

When designing an application that will communicate with a remote computer, a da (...)

clicks: 460 460 2007-04-02 2007-04-02 goto url (new window) msdn2.microsoft... goto myNews programacao


jQuery ListMenu Plugin

This jQuery plugin, developed in the iHwy Labs, allows you to easily convert a l (...)

clicks: 374 374 2009-10-18 2009-10-18 goto url (new window) ihwy.com/labs/j... goto myNews programacao


Javascript on the Server

Running Javascript on the server seems to be gaining in popularity. Last year I (...)

clicks: 460 460 2007-07-12 2007-07-12 goto url (new window) bluishcoder.co.... goto myNews programacao


Some C# Coding Guidelines

My goal is to add more to this in the future, but this is a very good start. I n (...)

clicks: 418 418 2007-03-24 2007-03-24 goto url (new window) patrick.veverka... goto myNews programacao


Language Equivalents

This article summarize popular programming concepts with side-by-side code examp (...)

clicks: 286 286 2009-01-23 2009-01-23 goto url (new window) dotnetoutsource... goto myNews programacao


Blocks - an alternative for Closures ?

The discussion about Closures for Java is still an ongoing issue and haven't los (...)

clicks: 380 380 2008-05-08 2008-05-08 goto url (new window) gleichmann.word... goto myNews programacao