Re: Collection Question
Robert Virkus <[email protected]>
| Newsgroups | gmane.comp.java.sun.kvm |
|---|---|
| Message-ID | <[email protected]> |
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 [email protected] and include in > the body > of the message "signoff KVM-INTEREST". For general help, send > email to > [email protected] 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 > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > <HTML><HEAD> > <META http-equiv=3DContent-Type content=3D"text/html; = > charset=3Dus-ascii"> > <META content=3D"MSHTML 6.00.2900.3157" name=3DGENERATOR></HEAD> > <BODY> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial size=3D2>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. </FONT></SPAN></DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial=20 > size=3D2></FONT></SPAN> </DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial size=3D2>I > am = > considering=20 > these two approaches and wants some opinons</FONT></SPAN></DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial=20 > size=3D2></FONT></SPAN> </DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial 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</FONT></SPAN></DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial size=3D2>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</FONT></SPAN></DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial=20 > size=3D2></FONT></SPAN> </DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial = > 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</FONT></SPAN></DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial=20 > size=3D2></FONT></SPAN> </DIV> > <DIV><SPAN class=3D760340318-14092007><FONT face=3DArial=20 > size=3D2>Thanks</FONT></SPAN></DIV> > <DIV> </DIV> > <STYLE> > <!-- > A.psl { > TEXT-DECORATION:none; COLOR: #4e81c4 > } > A:hover { > TEXT-DECORATION: underline > } > A.psl:hover { > COLOR: #999999 > } > noro { > FONT-SIZE: 8pt; COLOR: #4e81c4; FONT-FAMILY: > Verdana,Arial,fixed > } > tiny { > FONT-SIZE: 1pt > } > logotext { > TEXT-DECORATION: none; FONT-SIZE: 10pt; FONT-FAMILY: = > Verdana,Arial,fixed > } > A.brand { > FONT-SIZE: 7pt; COLOR: #ffffff; FONT-FAMILY: > Verdana,Arial,fixed; = > TEXT-DECORATION: underline > } > --> > </STYLE> > > <DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML> > =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 [email protected] and include in > the body > of the message "signoff KVM-INTEREST". For general help, send > email to > [email protected] 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: [email protected] 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 [email protected] and include in the body of the message "signoff KVM-INTEREST". For general help, send email to [email protected] and include in the body of the message "help".