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


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

lookup by EnumSet

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject lookup by EnumSet
Date Tue, 28 Feb 2012 05:55:59 -0800
Organization Canadian Mind Products
Lines 35
Message-ID <3kmpk7lno3fehkr0o21b4dqvhoijmpehbq@4ax.com> (permalink)
Reply-To Roedy Green <see_website@mindprod.com.invalid>
NNTP-Posting-Host Z2l1DcCELS0rATq8NqV4Sw.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
X-Notice Filtered by postfilter v. 0.8.2
X-Newsreader Forte Agent 6.00/32.1186
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:12490

Show key headers only | View raw


I had a long and annoying dream that there was a Java Collection that
let you look up by EnumSet.  It was not a simple Map. 

It worked something like this: You could assign a set of binary
attributes to a Person, e.g. male/female, fat, thin, average, atheist,
Christian, Moslem, Jew, Buddhist. Asian, European, African, North
American, South American..

Then you could ask for all the fat or average females, Buddhist but
not Asian.

You might specify an EnumSet for what you want and one for what you
don't want.  Anything not specified in either does not matter.

In the dream I was trying to write example code and an entry in the
Java glossary. When I woke, I could not think of such a class, and
further it was not obvious how one could be implemented.

I wondered how you would do it.

I thought you might extract the attributes into an array of longs and
check each one for compliance with your masks.

If the sets were stable, you might extract a BitSet for each
attribute, and do logical operations on giant bit strings of the
relevant bits.

I vaguely recall SQL databases optimising queries of this type by
transparently building inverse look up indexed.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
One of the most useful comments you can put in a program is 
"If you change this, remember to change ?XXX? too".
 

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


Thread

lookup by EnumSet Roedy Green <see_website@mindprod.com.invalid> - 2012-02-28 05:55 -0800
  Re: lookup by EnumSet Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-02-28 07:03 -0800
    Re: lookup by EnumSet Roedy Green <see_website@mindprod.com.invalid> - 2012-02-28 15:22 -0800
  Re: lookup by EnumSet Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-02-28 09:27 -0600
    Re: lookup by EnumSet Lew <noone@lewscanon.com> - 2012-02-28 09:31 -0800
      Re: lookup by EnumSet Robert Klemme <shortcutter@googlemail.com> - 2012-02-28 23:08 +0100
  Re: lookup by EnumSet Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-02-28 08:51 -0800
  Re: lookup by EnumSet Robert Klemme <shortcutter@googlemail.com> - 2012-02-28 23:08 +0100
    Re: lookup by EnumSet Robert Klemme <shortcutter@googlemail.com> - 2012-03-01 01:22 -0800
  Re: lookup by EnumSet Wanja Gayk <brixomatic@yahoo.com> - 2012-02-29 11:06 +0100

csiph-web