Skip to main content

Collection Question

1 reply [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Robert Virkus

Hi Chris,

you might want to consider using J2ME Polish's IntHashMap, which is
an collection optimized for int keys.
http://www.j2mepolish.org/javadoc/j2me/de/enough/polish/util/
IntHashMap.html
http://www.j2mepolish.org/mobile/j2mepolish-2.0-Preview.jar

Best,
Robert

On Sep 14, 2007, at 20:07 , Chris Rotberg wrote:

> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_04BE_01C7F6BF.817FC7D0
> Content-Type: text/plain;
> charset="us-ascii"
> Content-Transfer-Encoding: 7bit
>
> I currently have a Vector that I use to store XML type Strings. I loop
> through and read the Id of each using String searches. The
> searching is
> starting to slow as the list increases and I want to optimize it.
>
> I am considering these two approaches and wants some opinons
>
> 1. Create a class that has a int Id and a value String and then add
> that to
> the vector and look for specific Id before I read the String
> 2. Create a HashTable and use the int Id as a key (does key allow
> duplicates) and then look for the specific Id before I read the String
>
> Question: Is a custom class in a Vector more overhead that a
> HashTable with
> keys and Strings and which is faster
>
> Thanks
>
>
>
> ======================================================================
> =====
> To unsubscribe, send email to listserv@java.sun.com and include in
> the body
> of the message "signoff KVM-INTEREST". For general help, send
> email to
> listserv@java.sun.com and include in the body of the message "help".
>
> ------=_NextPart_000_04BE_01C7F6BF.817FC7D0
> Content-Type: text/html;
> charset="us-ascii"
> Content-Transfer-Encoding: quoted-printable
>
>
>
> > charset=3Dus-ascii">
>
>
>

I =
> currently have a=20
> Vector that I use to store XML type Strings. I loop through and
> read the =
> Id of=20
> each using String searches. The searching is starting to slow as the =
> list=20
> increases and I want to optimize it.

>
> size=3D2> 

>
I
> am =
> considering=20
> these two approaches and wants some opinons

>
> size=3D2> 

>
1. =
> Create a class=20
> that has a int Id and a value String and then add that to the
> vector and =
> look=20
> for specific Id before I read the String

>
2. =
> Create a=20
> HashTable and use the int Id as a key (does key allow duplicates)
> and =
> then look=20
> for the specific Id before I read the String

>
> size=3D2> 

>
> size=3D2>Question: Is a=20
> custom class in a Vector more overhead that a HashTable with keys
> and =
> Strings=20
> and which is faster

>
> size=3D2> 

>
> size=3D2>Thanks

>
 

>

>
>

 

> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> 3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3
> D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> =3D=3D=3D=3D=3D
> To unsubscribe, send email to listserv@java.sun.com and include in
> the body
> of the message "signoff KVM-INTEREST". For general help, send
> email to
> listserv@java.sun.com and include in the body of the message "help".
>
> ------=_NextPart_000_04BE_01C7F6BF.817FC7D0--

--
Robert Virkus
CEO Enough Software
Sögestr. 70
28195 Bremen
Germany

Email: Robert.Virkus@enough.de
Phone: +49 - (0)421 - 8409 938
Fax: +49 - (0)421 - 9889 132
Mobile: +49 - (0)160 - 7788 203
ICQ: 194752667

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".