The collections API is superior to using 1.1's Vector and Hashtable classes.
However, the time it would take to convert, and the real benefits that such
migration gives you should be considered too. Vector implements List - so
using 1.1 collection classes with the Java 2 Collections API is perfectly
feasible. It allows a slow migration, rather than requiring lots of work to
achieve no functionality increases.

I do NOT suggest switching from Hashtable to List. (Particularly not to
ArrayList - which does not guarantee that elements will be ordered.) I
suggest a TreeMap. Moving from a Map (Hashtable implements the Map
interface) to a List will just create loads of extra work that you don't
need. Note that this advice is more generic than that required by the
original poster, who seems to be considering a Map where a List would
suffice.

I would add that if you are looking for as-fast-as-possible speed, don't
consider Java! If you are not looking for as-fast-as-possible speed, read a
book on Java performance (such as "Java Platform Performance", which does
deal with the Collections API). I would expect things other than which
Collection to use to affect execution speed a lot more. As always, it
depends on your context, your application, and your circumstances. Profile,
to find out what is *really* slowing things down. Never ever guess. You'll
be wrong.

-----Original Message-----
From: Ross Burton <[EMAIL PROTECTED]>
To: Jose Antonio Lamas <[EMAIL PROTECTED]>
Cc: Advanced-Swing <[EMAIL PROTECTED]>
Date: Tuesday, July 24, 2001 10:05
Subject: Re: Array, Vector or Hashtable to keep the table's data model ?


>On 24 Jul 2001 10:30:54 +0200, Jose Antonio Lamas wrote:
>> Hi,
>>
>> I have used Array, Vector and Hashtable to keep the table's data model,
but
>> I have a question/comment.
>>
>> Which is the best alternative? The two objetives are speed and ease of
use.
>>
>> I think:
>>
>> -- PROS--
>>  Array is fast and easy.
>>  Vector has a variable size.
>>  Hashtable is fast (is Array faster than Hashtable?).
>>
>> -- CONS --
>>  Array has a fixed length.
>>  Vector is not very fast (because of castings) and not so easy.
>>  Hashtable is not so easy as Array.
>
>Firstly, stop using the JDK 1.1 containers and move to Collections -
>Vector -> ArrayList, Hashtable -> HashMap/HashSet.
>
>A vector is a thin wrapper around an array (to resize it as needed).  If
>you need raw speed, use an array but Vectors (and ArrayLists, which are
>better) are very handy as they can resize and can be used as general
>Lists.  Casting isn't that slow really, and all generic containers (ones
>which store Objects) will require casting.
>
>Hash tables are not ordered however, which is not what you want for a
>table model.  I suggest you start looking at java.util.List and see what
>subclasses are available - I reccomment ArrayList.
>
>Ross
>--
>Ross Burton                     Software Engineer
>OneEighty Software Ltd          Tel: +44 20 8680 8712
>Cygnet House                    Fax: +44 20 8680 8453
>12-14 Sydenham Road             [EMAIL PROTECTED]
>Croydon, Surrey CR9 2ET, UK     http://www.180sw.com./
>====================================================================
>Under the Regulation of Investigatory Powers (RIP) Act 2000 together
>with any and all Regulations in force pursuant to the Act OneEighty
>Software Ltd reserves the right to monitor any or all incoming or
>outgoing communications as provided for under the Act
>
>_______________________________________________
>Advanced-swing mailing list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/advanced-swing

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to