Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21781

Re: Index of List

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Index of List
Date 2013-01-26 19:22 -0800
Organization Canadian Mind Products
Message-ID <3r69g8ljnsoimgtc8srgutra3qa08nmejr@4ax.com> (permalink)
References <8fb20d2d-260b-42a1-9899-d038d2abfa5e@gg5g2000pbc.googlegroups.com>

Show all headers | View raw


On Fri, 25 Jan 2013 09:07:33 -0800 (PST), Subhabrata
<subhabangalore@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>
>I am a new programmer in Java.

HashSet will quickly tell you if a word is in a list, but it won't
give you any order.

You can export the data to a array or ArrayList and sort it.  Then you
can linearly scan for it or use binary search.

Or you can build a HashMap that gives you the order# given the word.

This all blows up in you face if you keep adding words,

see
http://mindprod.com/jgloss/hashset.html
http://mindprod.com/jgloss/hashmap.html
http://mindprod.com/jgloss/arraylist.html
http://mindprod.com/jgloss/array.html
http://mindprod.com/jgloss/binarysearch.html
http://mindprod.com/jgloss/sort.html

Your question may be ill-formed.  It seems to me there can be multiple
answers to the question.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development 
time. 
~ Tom Cargill  Ninety-ninety Law 

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Index of List Subhabrata <subhabangalore@gmail.com> - 2013-01-25 09:07 -0800
  Re: Index of List Tim Slattery <Slattery_T@bls.gov> - 2013-01-25 12:38 -0500
  Re: Index of List "John B. Matthews" <nospam@nospam.invalid> - 2013-01-25 12:48 -0500
  Re: Index of List Arne Vajhøj <arne@vajhoej.dk> - 2013-01-25 21:44 -0500
  Re: Index of List Roedy Green <see_website@mindprod.com.invalid> - 2013-01-26 19:22 -0800

csiph-web