This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: BitSet.[x]or does (not) grow BitSet


Mark Wielaard wrote:
> 
> I don't mind changing one or the other as long as they agree on the
> result.
> 
> The problem with my original statement was that it talked about growing
> the BitSet which is not actually what these tests check. What they check
> is the following:
> 
> - Given
>   BitSet a = {1,2,3}
>   BitSet b = {3,4,5}
>   BitSet c = a.xor(b);
> - Is the result
>   - c = {1,2}
>   since bits 4 and 5 were not explicitly set or cleared in a.
> or
>   - c = {1,2,4,5}
>   since bits 3 and 5 are set in b.
> 
> The language of BitSet.or() and BitSet.xor() is not clear to me about
> this issue. I arbitrarily took the interpretation of the first test. But
> since you recently rewrote the BitSet implementation for Classpath I am
> easily convinced that it should be the other way around :)

Well, a quick test on JDK 1.4 shows that Sun grows their BitSets (I
purposefully spaced the bits to be beyond the 64-bit boundaries of long,
to prove that growth is occuring):
$ cat Blah.java
class Blah
{
  public static void main(String[] args)
  {
    BitSet a = new BitSet();
    a.set(1);
    a.set(65);
    BitSet b = new BitSet();
    b.set(1);
    b.set(129);
    System.out.println(a + " " + b);
    a.xor(b);
    System.out.println(a);
  }
}
$ java Blah
{1, 65} {1, 129}
{65, 129}


-- 
This signature intentionally left boring.

Eric Blake             ebb9@email.byu.edu
  BYU student, free software programmer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]