<pedrocorreia.net ⁄>
 

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




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

The Truth About PHP Variables

I wanted to write this post to clear up what seems to be a common misunderstandi (...)

clicks: 339 339 2009-05-07 2009-05-07 goto url (new window) porteightyeight... goto myNews programacao


URL parsing and manipulation in .NET

While .NET has a couple of URI classes they're pretty useless. They don't decod (...)

clicks: 547 547 2006-07-10 2006-07-10 goto url (new window) damieng.com/blo... goto myNews programacao


jQuery Tip: Font Resizing With Animation Effects

Hey everyone. Sorry for not having a new tip published yesterday, I was feeling (...)

clicks: 421 421 2009-01-18 2009-01-18 goto url (new window) dev-tips.com/fe... goto myNews programacao


Javascript Drag and DropJavascript Drag and Drop

Some of the most exciting features of dynamic HTML are the least used. Instead o (...)

clicks: 626 626 2006-12-20 2006-12-20 goto url (new window) hunlock.com/blo... goto myNews programacao


How Do Locks Lock?

When I was 9 or so, I was convinced I could write my own operating system in GW- (...)

clicks: 337 337 2008-09-30 2008-09-30 goto url (new window) moserware.com/2... goto myNews programacao


ASP.NET Memory: Thou shalt not store UI objects in cache or session scope

Surprisingly the issue I wrote about in "the eventhandlers that made the memory (...)

clicks: 464 464 2008-06-03 2008-06-03 goto url (new window) blogs.msdn.com/... goto myNews programacao


Lambda expressions, Part I: Syntax

As I alluded to in my earlier entry, one of the features we're working on for LI (...)

clicks: 573 573 2006-12-10 2006-12-10 goto url (new window) panopticoncentr... goto myNews programacao


Functional C# - Forward Functional Composition

Before we get going, I wanted to revisit currying because I'm not sure that peop (...)

clicks: 276 276 2009-04-26 2009-04-26 goto url (new window) weblogs.asp.net... goto myNews programacao