🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #745

Re: list class

#745
From: elrond_III
Date: Tue, 21 Dec 2004 15:55
53 lines
3420 bytes
Scott wrote:
> Joerg,
>    I pasted below this message the code that I have. I think I did pretty 
> well on it. The only part I'm currently having an issue with is removing an 
> item from the array.I want to be able to remove one of the names and have 
> the other items fill the empty spot.  I know that there is a built in 
> function to do it, but I'd like a literal method that will show me step by 
> step what it's doing. As I've done with the other methods, like add, and 
> search, etc. Hope this helps.  Thanks for the help.
>  Scott

Hi!
This is the way i would to it manually, (undested ^^)

// rem_place is the place where we delete an item
for(int count = rem_place; count < (data.length - 1); count++) {
   data[count] = data[count + 1];
}
data[count + 1] = null;

but maybe arraycopy (i am not quite shure) is faster, because it just 
shifts your references, so all this may go in one step.... [please 
correct me if i am wrong]

cu
   Joerg


-----------
Something to think ^_^ (althoug for your example nonsence, maybe you 
want to try):
At the university you learn that seraching in a for loop is the most 
inefficient searching algorithm you can have. Where is the problem:
Assume we have a phone book of a city with, lets say 5 million entries 
and we search for the last name in the book we would need 5 million 
string compares for that.
So what would you do?
You might want to have the list sorted the hole time, so when you search 
you can f.e. ask for the first letter, and start searching near that 
letter in the array (interpolative search).
If you wan't to work with larger data like the one in an dictionary, and 
that it is quick and so on you might want to learn something about data 
structures and algorithms (there is a reference book from, �h, Sedgewick 
[hm, i think i spelled it wrong]).


-- 
--------------------------------------------------------------
Elrond_III      -==: Hack the World :==-
g:R->R; [a,b] in D(g) and g[a,b] in [a,b] and for all x1,x2 in [a,b]
|g(x1)-g(x2)|<=L*|x1-x2| with L <= 1 then one s in [a,b] exist with
s=g(s)
                                   -"Banachscher Fixpunktsatz"
Technical Details
Message-ID: <41c847c2$0$26996$3b214f66@aconews.univie.ac.at>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-zh.switch.ch!switch.ch!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail
References: <0Nkwd.12381$Ae.6831@newsread1.dllstx09.us.to.verio.net> <41c82ae7$0$22342$3b214f66@aconews.univie.ac.at> <zDWxd.12514$Ae.10718@newsread1.dllstx09.us.to.verio.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,62cee13431c73458
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-zh.switch.ch!switch.ch!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail
Date: Tue, 21 Dec 2004 16:55:02 +0100
From: elrond_III <elrond_III@gmx.at>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040608
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: list class
References: <0Nkwd.12381$Ae.6831@newsread1.dllstx09.us.to.verio.net> <41c82ae7$0$22342$3b214f66@aconews.univie.ac.at> <zDWxd.12514$Ae.10718@newsread1.dllstx09.us.to.verio.net>
In-Reply-To: <zDWxd.12514$Ae.10718@newsread1.dllstx09.us.to.verio.net>
X-Enigmail-Version: 0.84.1.0
X-Enigmail-Supports: pgp-inline, pgp-mime
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 53
Message-ID: <41c847c2$0$26996$3b214f66@aconews.univie.ac.at>
NNTP-Posting-Host: a-70.dsl.tu-graz.ac.at
X-Trace: 1103644610 aconews.univie.ac.at 26996 129.27.232.70
X-Complaints-To: abuse@univie.ac.at