Article View: borland.public.jbuilder.java.language
Article #651Re: list class
From: elrond_III
Date: Tue, 21 Dec 2004 17:23
Date: Tue, 21 Dec 2004 17:23
51 lines
3076 bytes
3076 bytes
Scott wrote:
> Joerg,
> That was a huge help. I greatly appreciate it. I'm currently moving onto
> the next little project. The dictionary class is similar to the List class.
> What I want to do is basically have two lists. One with the key/words and
> one with the values/definitions. I'd like to be able to add, remove, search
> by word, search by definition, list alphabetically, etc...that kind of
> stuff. I understand that it would be pretty similar to this list calss. If I
> understand correctly, I should be able to use this list class I've created
> to basically perform thos operations upon the new dictionary. Just a little
> unclear how it connects. Thanks for the help.
> Scott
Hm, there are plenty of ways to connect that classes. In your current
interface it maybe useful to have the last value in your super class too.
class Dictionary {
private List keys_;
private List values_;
private int last_position_;
Dictionary() {
this.keys_ = new List();
this.values_ = new List();
}
}
now you can do something like:
public String lookup(String s) {
int i = keys.locate(s);
return values.get(i);
}
or (the same but shorter):
public String lookup(String s) {
retrun values.get(keys.locate(s));
}
--
--------------------------------------------------------------
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:
<41c85c77$0$30502$3b214f66@aconews.univie.ac.at>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!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> <JSYxd.12521$Ae.11937@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!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Date: Tue, 21 Dec 2004 18:23:23 +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> <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> <JSYxd.12521$Ae.11937@newsread1.dllstx09.us.to.verio.net> In-Reply-To: <JSYxd.12521$Ae.11937@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: 51 Message-ID: <41c85c77$0$30502$3b214f66@aconews.univie.ac.at> NNTP-Posting-Host: a-183.dsl.tu-graz.ac.at X-Trace: 1103649911 aconews.univie.ac.at 30502 129.27.232.183 X-Complaints-To: abuse@univie.ac.at