Article View: borland.public.jbuilder.java.language
Article #653Re: List class, again...I know...I'm not a pest just learning
From: elrond_III
Date: Tue, 21 Dec 2004 21:21
Date: Tue, 21 Dec 2004 21:21
59 lines
3565 bytes
3565 bytes
Scott wrote:
> What I'm trying to do is remove an item without using a for, or a
> loop of any kind. For example, a number of words from a hungarian
> dictionary. You are told to remove the word Szabadsag.(Some street in
> Hungary). It won't start with the word repeat( or for or loop or any
> other similar word which is what our method does.
If you use a loop shouldn't affect what word you can or can't delete!
> //removes an item from the list public void remove(String s) { for
> (int count = 0; count < (data.length - 1); count++) { data[count] =
> data[count + 1]; } data[count + 1] = ""; }
In this version you are always deleting the first word. This fact
doesn't have to do with the fact you are using a loop but with the fact
you start at the beginning. (int count = 0;)
If you want to delete another word elswhere in your array, just start at
this point.
f.e.:
array:
[1] [2] [3] [4]
hi ho hu ha
we want to delete *hu* then we do:
for(int count = 3; count < (data.length - 1); count++) {
data[count] = data[count + 1];
}
data[count + 1] = "";
I wrote you a code bevore where I did the following:
public void remove(String s) {
int location = locate(s);
for(int counter = rem_place; counter < (data.length - 1); counter++) {
data[counter] = data[count + 1];
}
data[counter 1] = "";
}
You see that I get the starting point first!
(You can also write the function in various ways, one in wich you maybe
see clearer what i am doing:)
public void remove(String s) {
for(int counter = locate(s); counter < (data.length - 1); counter++) {
data[counter] = data[count + 1];
}
data[counter + 1] = "";
}
--
--------------------------------------------------------------
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:
<41c8944a$0$15044$3b214f66@aconews.univie.ac.at>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!newspeer1.nwr.nac.net!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-mailReferences:
<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> <41c847c2$0$26996$3b214f66@aconews.univie.ac.at> <IaYxd.12520$Ae.9292@newsread1.dllstx09.us.to.verio.net> <41c857ef$0$26996$3b214f66@aconews.univie.ac.at> <ZY_xd.12526$Ae.2928@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-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!newspeer1.nwr.nac.net!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 22:21:34 +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, again...I know...I'm not a pest just learning 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> <41c847c2$0$26996$3b214f66@aconews.univie.ac.at> <IaYxd.12520$Ae.9292@newsread1.dllstx09.us.to.verio.net> <41c857ef$0$26996$3b214f66@aconews.univie.ac.at> <ZY_xd.12526$Ae.2928@newsread1.dllstx09.us.to.verio.net> In-Reply-To: <ZY_xd.12526$Ae.2928@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=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lines: 59 Message-ID: <41c8944a$0$15044$3b214f66@aconews.univie.ac.at> NNTP-Posting-Host: a-183.dsl.tu-graz.ac.at X-Trace: 1103664202 aconews.univie.ac.at 15044 129.27.232.183 X-Complaints-To: abuse@univie.ac.at