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


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

Re: BitSet vs BigInteger (false Android doc)

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: BitSet vs BigInteger (false Android doc)
Date Tue, 6 Sep 2011 14:51:46 -0700 (PDT)
Organization http://groups.google.com
Lines 47
Message-ID <b19a0af2-c9a5-4367-bfc4-ae16c95fee6d@glegroupsg2000goo.googlegroups.com> (permalink)
References <j3rbtv$d5g$1@news.albasani.net> <4e613b65$0$311$14726298@news.sunsite.dk> <yJCdnamwfpVooPzTnZ2dnUVZ_umdnZ2d@earthlink.com> <j3rflb$lh6$2@news.albasani.net> <KOmdnWyhfYV_FPzTnZ2dnUVZ_s-dnZ2d@earthlink.com> <j3tqr7$vp8$1@news.albasani.net> <_ZGdna1ucfWYH__TnZ2dnUVZ_oudnZ2d@earthlink.com> <j3u3me$k4s$1@news.albasani.net> <4e655c24$0$308$14726298@news.sunsite.dk> <j44ga5$970$1@news.albasani.net> <pbmdnZtHEfnnxPvTnZ2dnUVZ_uWdnZ2d@earthlink.com> <j460hs$u3p$1@news.albasani.net>
Reply-To comp.lang.java.programmer@googlegroups.com
NNTP-Posting-Host 2620:0:1000:437c:224:d7ff:fe69:5838
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1315345906 353 127.0.0.1 (6 Sep 2011 21:51:46 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Tue, 6 Sep 2011 21:51:46 +0000 (UTC)
In-Reply-To <j460hs$u3p$1@news.albasani.net>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:437c:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7638

Show key headers only | View raw


Jan Burse wrote:
> Patricia Shanahan schrieb:
>> conversions. The combination of the comment in question and reading the
>> code shows that they did not take that path. Instead, they always
>> convert for bit manipulation and advise use of BitSet instead.
> 
> The Android comment can be corrected as follows:
>     "It is adviced [sic] to use BitSet if only positive bit patterns
>      come into play and if it is possible to use inline modifications."

The Android comment is not incorrect to begin with.

> But the comment should maybe also include a warning, that using
> objects with inline modifications can lead to more programming
> errors. Reasons are for example that the objects are now mutable
> and thus various side effects can occur. Here is an example:
> 
>      Hashtable tab = new Hashtable();

'Hashtable'?  Really?

>      BitSet bits = new BitSet();
>      tab.put(bits,"A");
>      bits.flip(3);
> 
> The above will result in a slightly broken hashtable. Although

This is an example of the general principle that a mutable key in a 'Map' can mess things up, if you change the key while the 'Map' holds it.  It hardly requires a warning in every mutable class's Javadocs.

> the entries in a hashtable do store the hash once it is computed.
> But the following code will not work as expected:
> 
>      Enumerated en=tab.keys();

'Enumerated'?  Really?

>      while (en.hasMoreElements()) {
>         BitSet bits=en.nextElement();
>         System.out.println("key="+bits+", value="+tab.get(bits));
>      }
> 
> But I guess you all know about these dangers.

Anyone familiar with the dangers of mutable keys in a 'Map' knows at least something about these dangers.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 21:48 +0200
  Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-02 16:23 -0400
    Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-02 13:34 -0700
      Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 22:51 +0200
        Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-02 18:58 -0700
          Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-03 20:15 +0200
            Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-03 12:37 -0700
              Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-03 22:46 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-03 16:32 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-04 02:58 +0200
                Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 19:32 -0400
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 08:58 +0200
                Re: BitSet vs BigInteger (false Android doc) Lew <lewbloch@gmail.com> - 2011-09-06 00:41 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 11:57 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:12 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:44 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 12:02 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 13:38 -0700
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 10:33 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 22:28 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-06 22:41 +0200
                Re: BitSet vs BigInteger (false Android doc) Patricia Shanahan <pats@acm.org> - 2011-09-06 14:34 -0700
                Re: BitSet vs BigInteger (false Android doc) Lew <lewbloch@gmail.com> - 2011-09-06 14:51 -0700
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-07 00:33 +0200
                Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-07 00:40 +0200
            Re: BitSet vs BigInteger (false Android doc) Arne Vajhøj <arne@vajhoej.dk> - 2011-09-05 19:26 -0400
      Re: BitSet vs BigInteger (false Android doc) Robert Klemme <shortcutter@googlemail.com> - 2011-09-03 17:01 +0200
    Re: BitSet vs BigInteger (false Android doc) Jan Burse <janburse@fastmail.fm> - 2011-09-02 22:49 +0200
      Re: BitSet vs BigInteger (false Android doc) Gene Wirchenko <genew@ocis.net> - 2011-09-02 14:48 -0700
  Re: BitSet vs BigInteger (false Android doc) Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-03 13:54 -0400

csiph-web