Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Re: correct use of TreeSet (http://www.velocityreviews.com/forums/t150672-re-correct-use-of-treeset.html)

Stefan Ram 02-26-2006 12:24 AM

Re: correct use of TreeSet
 
Luc wrote:
>I have a LinkedList of File objects and want to sort them by
>size to find duplicates.


They should implement

http://download.java.net/jdk6/docs/a...omparable.html

appropriately, then you can use

http://download.java.net/jdk6/docs/a...java.util.List)



Roedy Green 02-26-2006 12:09 PM

Re: correct use of TreeSet
 
On 26 Feb 2006 00:24:58 GMT, ram@zedat.fu-berlin.de (Stefan Ram)
wrote, quoted or indirectly quoted someone who said :

>>I have a LinkedList of File objects and want to sort them by
>>size to find duplicates.

>
> They should implement
>
>http://download.java.net/jdk6/docs/a...omparable.html
>
> appropriately, then you can use
>
>http://download.java.net/jdk6/docs/a...java.util.List)
>


for an memory-efficient implementation of that, see the MiniFD and FD
classes in the Replicator source. FD = File Descriptor.

see http://mindprod.com/products1.html#REPLICATOR
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Stefan Schulz 02-26-2006 03:47 PM

Re: correct use of TreeSet
 
Since these are java.io.File objects (As far as i understand the OP),
you should implement a Comparator that compares files by size, and
stick that to Collections.sort()



All times are GMT. The time now is 03:53 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.