I'm fairly new to Java and I'm trying to make a program that will store
certain objects and then list them depending on their features. I hope this
makes sense and I hope I get the terminology right!
For example,
I want to store instances of "people" and they need to have true or false to
the following questions.
Are they male?
Are they tall?
Do they have brown eyes?
Then I want to be able to list all of the people who are not male, all that
are tall and all that have brown eyes.
What is the best way to store them and how can I return the people with brown
eyes, for example?
> I'm fairly new to Java ..
Just a quick note that those new to Java are best helped
on a usenet newsgroup called comp.lang.java.help[1], it will
appear as 'First Aid' through the JavaKB[2] web interface.
[1] <http://www.physci.org/codes/javafaq.jsp#cljh>
[2] <http://www.physci.org/codes/javafaq.jsp#usenet>
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Secreted by the Comedy Bee
Malte wrote:
>> Hi,
>>
>[quoted text clipped - 13 lines]
No, you're basically creating DB indexes (each HashSet is an index) and
there's no way around it. If your objects have a large number of attributes
and/or you don't know in advance what attributes you're going to search on,
you're better off with an SQL database (e.g. HSQLDB). With small number of
attributes you'll use hashes. With a single attribute you could use sorted
list.
Another thing SQL makes easier is finding intersections, unions, etc. of
subsets: e.g. all tall people with brown eyes and dark or red hair.
Dima
--
Riding roughshod over some little used trifle like the English language is not a
big deal to an important technology innovator like Microsoft. They did just that
by naming a major project dot-Net (".Net"). Before that, a period followed by a
capital letter was used to mark a sentence boundary. --T. Gottfried, RISKS 21.91
>Then I want to be able to list all of the people who are not male, all that
>are tall and all that have brown eyes.
>What is the best way to store them and how can I return the people with brown
>eyes, for example?
look at BitSet. In Java 5, loot at EnumSet.
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
You might want to add that JavaKB not only renames Usenet groups, but
also doesn't tell people that these groups are indeed Usenet groups, and
not a JavaKB invention. And, JavaKB strips of information not only from
the message header, but also the message body. The later is highly
questionable behavior.
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
> Andrew Thompson wrote:
>> Just a quick note that those new to Java are best helped
>> on a usenet newsgroup called comp.lang.java.help[1], it will
>> appear as 'First Aid' through the JavaKB[2] web interface.
>
> You might want to add that JavaKB not only renames Usenet groups, but
> also doesn't tell people that these groups are indeed Usenet groups, and
> not a JavaKB invention. And, JavaKB strips of information not only from
> the message header, but also the message body. The later is highly
> questionable behavior.
'strips information .. from message body'?
Can you provide a link that demonstrates?
I 'crash banged' around JavaKB early on, looking for
any indication that they edited or mangled messages,
but could find none.
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Beats A Hard Kick In The Face
Compare
to
http://groups.google.com/group/comp.lang.java.programmer/msg/0e931b0987671bad?dmode=source
Do you note the missing attributions "... xyz wrote ..."?
> Andrew Thompson wrote:
>> 'strips information .. from message body'?
>> Can you provide a link that demonstrates?
> Do you note the missing attributions "... xyz wrote ..."?
Got it. I will make a note of it when I get a moment,
but I must admit it is not as serious as I thought.
Having dealt with groups beta ..
- hiding sigs automatically,
- encouraging top-posting by hiding 'quoted text' by default, and
- losing around 40% of old posts,
..and dealing with other web interfaces that actually
*screened* posts out of their own site - specifically
posts slagging them...
..It just does not seem that world shattering.
Maybe they are just wearing me down. I feel we need
to accept that some aspects of interaction though
Usenet Newsgroups *will* change as a result of the
latest (last year or so) changes to the web interfaces.
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Deciphered From Crop Circles