nus-yam/ex-repair huggingface dataset:
Program: 90331
Project: 90331
Buggy source:
@Test public void flipTestBigA(){
  final int numCases=1000;
  final BitSet bs=new BitSet();
  final Random r=new Random(3333);
  int checkTime=2;
  RoaringBitmap rb1=new RoaringBitmap(), rb2=null;
  for (int i=0; i < numCases; ++i) {
    final int start=r.nextInt(65536 * 20);
    int end=r.nextInt(65536 * 20);
    if (r.nextDouble() < 0.1)     end=start + r.nextInt(100);
    if ((i & 1) == 0) {
      rb2=RoaringBitmap.flip(rb1,start,end);
      RoaringBitmap tmpsh=slowflip(rb1,start,end);
      assert(tmpsh.equals(rb2));
      rb1.flip(r.nextInt(65536 * 20),r.nextInt(65536 * 20));
    }
 else {
      rb1=RoaringBitmap.flip(rb2,start,end);
      RoaringBitmap tmpsh=slowflip(rb2,start,end);
      assert(tmpsh.equals(rb1));
      rb2.flip(r.nextInt(65536 * 20),r.nextInt(65536 * 20));
    }
    if (start < end)     bs.flip(start,end);
    if (r.nextDouble() < 0.2 && (i & 1) == 0) {
      final RoaringBitmap mask=new RoaringBitmap();
      final BitSet mask1=new BitSet();
      final int startM=r.nextInt(65536 * 20);
      final int endM=startM + 100000;
      mask.flip(startM,endM);
      mask1.flip(startM,endM);
      mask.flip(0,65536 * 20 + 100000);
      mask1.flip(0,65536 * 20 + 100000);
      rb2.and(mask);
      bs.and(mask1);
    }
    if (i > checkTime) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ rb2.getCardinality());
      final RoaringBitmap rb=(i & 1) == 0 ? rb2 : rb1;
      final boolean status=equals(bs,rb);
      Assert.assertTrue(status);
      checkTime*=1.5;
    }
  }
}

Fixed version (ground truth):
@Test public void flipTestBigA(){
  final int numCases=1000;
  final BitSet bs=new BitSet();
  final Random r=new Random(3333);
  int checkTime=2;
  RoaringBitmap rb1=new RoaringBitmap(), rb2=null;
  for (int i=0; i < numCases; ++i) {
    final int start=r.nextInt(65536 * 20);
    int end=r.nextInt(65536 * 20);
    if (r.nextDouble() < 0.1)     end=start + r.nextInt(100);
    if ((i & 1) == 0) {
      rb2=RoaringBitmap.flip(rb1,start,end);
      int r1=r.nextInt(65536 * 20);
      int r2=r.nextInt(65536 * 20);
      rb1.flip(r1,r2);
    }
 else {
      rb1=RoaringBitmap.flip(rb2,start,end);
      int r1=r.nextInt(65536 * 20);
      int r2=r.nextInt(65536 * 20);
      rb2.flip(r1,r2);
    }
    if (start < end) {
      bs.flip(start,end);
    }
    if (r.nextDouble() < 0.2 && (i & 1) == 0) {
      final RoaringBitmap mask=new RoaringBitmap();
      final BitSet mask1=new BitSet();
      final int startM=r.nextInt(65536 * 20);
      final int endM=startM + 100000;
      mask.flip(startM,endM);
      mask1.flip(startM,endM);
      mask.flip(0,65536 * 20 + 100000);
      mask1.flip(0,65536 * 20 + 100000);
      rb2.and(mask);
      bs.and(mask1);
    }
    if (i > checkTime) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ rb2.getCardinality());
      final RoaringBitmap rb=(i & 1) == 0 ? rb2 : rb1;
      final boolean status=equals(bs,rb);
      Assert.assertTrue(status);
      checkTime*=1.5;
    }
  }
}
Program: 90332
Project: 90332
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  bitmap1.newand(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  RoaringBitmap b1=bitmap1.clone();
  b1.newand(bitmap2);
  return b1;
}
Program: 90333
Project: 90333
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  bitmap1.and(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  RoaringBitmap b1=bitmap1.clone();
  b1.and(bitmap2);
  return b1;
}
Program: 90334
Project: 90334
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  return bitmap1.clone().newand(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  RoaringBitmap b1=bitmap1.clone();
  b1.newand(bitmap2);
  return b1;
}
Program: 90335
Project: 90335
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  return bitmap1.clone().and(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  RoaringBitmap b1=bitmap1.clone();
  b1.and(bitmap2);
  return b1;
}
Program: 90336
Project: 90336
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  return bitmap1.clone().newand(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_newand(){
  RoaringBitmap b1=bitmap1.clone();
  b1.newand(bitmap2);
  return b1;
}
Program: 90337
Project: 90337
Buggy source:
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  return bitmap1.clone().and(bitmap2);
}

Fixed version (ground truth):
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public RoaringBitmap inplace_and(){
  RoaringBitmap b1=bitmap1.clone();
  b1.and(bitmap2);
  return b1;
}
Program: 90338
Project: 90338
Buggy source:
@Override public Container limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality <= MAX_CAPACITY) {
    ArrayContainer ac=new ArrayContainer(maxcardinality);
    int pos=0;
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.length); ++k) {
      long bitset=bitmap[k];
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        ac.content[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  BitmapContainer bc=new BitmapContainer(maxcardinality,this.bitmap);
  int s=Util.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.length - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap[bc.bitmap.length - 1 - k]=0;
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap[s / 64]=(bc.bitmap[s / 64] << (64 - lastword)) >> (64 - lastword);
  }
  return bc;
}

Fixed version (ground truth):
@Override public Container limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality < ArrayContainer.DEFAULT_MAX_SIZE) {
    ArrayContainer ac=new ArrayContainer(maxcardinality);
    int pos=0;
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.length); ++k) {
      long bitset=bitmap[k];
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        ac.content[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  BitmapContainer bc=new BitmapContainer(maxcardinality,this.bitmap);
  int s=Util.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.length - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap[bc.bitmap.length - 1 - k]=0;
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap[s / 64]=(bc.bitmap[s / 64] << (64 - lastword)) >> (64 - lastword);
  }
  return bc;
}
Program: 90339
Project: 90339
Buggy source:
protected void resetBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  bitmap[firstword]&=~(~0L << start);
  for (int i=firstword + 1; i < endword; i++)   bitmap[i]=0;
  bitmap[endword]&=~(~0L >>> -end);
}

Fixed version (ground truth):
protected static void resetBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword]&=~((~0L << start) & (~0L >>> -end));
    return;
  }
  bitmap[firstword]&=~(~0L << start);
  for (int i=firstword + 1; i < endword; i++)   bitmap[i]=0;
  bitmap[endword]&=~(~0L >>> -end);
}
Program: 90340
Project: 90340
Buggy source:
protected void flipBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  bitmap[firstword]^=~0L << start;
  for (int i=firstword + 1; i < endword; i++)   bitmap[i]=~bitmap[i];
  bitmap[endword]^=~0L >>> -end;
}

Fixed version (ground truth):
protected static void flipBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  bitmap[firstword]^=~(~0L << start);
  ;
  for (int i=firstword; i < endword; i++)   bitmap[i]=~bitmap[i];
  bitmap[endword]^=~0L >>> -end;
}
Program: 90341
Project: 90341
Buggy source:
protected void setBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  bitmap[firstword]|=~0L << start;
  for (int i=firstword + 1; i < endword; i++)   bitmap[i]=~0;
  bitmap[endword]|=~0L >>> -end;
}

Fixed version (ground truth):
protected static void setBitmapRange(long[] bitmap,int start,int end){
  if (start == end)   return;
  int firstword=start / 64;
  int endword=(end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword]|=(~0L << start) & (~0L >>> -end);
    return;
  }
  bitmap[firstword]|=~0L << start;
  for (int i=firstword + 1; i < endword; i++)   bitmap[i]=~0;
  bitmap[endword]|=~0L >>> -end;
}
Program: 90342
Project: 90342
Buggy source:
@Override public MappeableContainer limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality <= MAX_CAPACITY) {
    MappeableArrayContainer ac=new MappeableArrayContainer(maxcardinality);
    int pos=0;
    short[] cont=ac.content.array();
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.limit()); ++k) {
      long bitset=bitmap.get(k);
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        cont[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  MappeableBitmapContainer bc=new MappeableBitmapContainer(maxcardinality,this.bitmap);
  int s=BufferUtil.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.limit() - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap.put(bc.bitmap.limit() - 1 - k,0);
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap.put(s / 64,(bc.bitmap.get(s / 64) << (64 - lastword)) >> (64 - lastword));
  }
  return bc;
}

Fixed version (ground truth):
@Override public MappeableContainer limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality < MappeableArrayContainer.DEFAULT_MAX_SIZE) {
    MappeableArrayContainer ac=new MappeableArrayContainer(maxcardinality);
    int pos=0;
    short[] cont=ac.content.array();
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.limit()); ++k) {
      long bitset=bitmap.get(k);
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        cont[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  MappeableBitmapContainer bc=new MappeableBitmapContainer(maxcardinality,this.bitmap);
  int s=BufferUtil.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.limit() - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap.put(bc.bitmap.limit() - 1 - k,0);
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap.put(s / 64,(bc.bitmap.get(s / 64) << (64 - lastword)) >> (64 - lastword));
  }
  return bc;
}
Program: 90343
Project: 90343
Buggy source:
@Override public Container limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality < ArrayContainer.DEFAULT_MAX_SIZE) {
    ArrayContainer ac=new ArrayContainer(maxcardinality);
    int pos=0;
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.length); ++k) {
      long bitset=bitmap[k];
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        ac.content[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  BitmapContainer bc=new BitmapContainer(maxcardinality,this.bitmap);
  int s=Util.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.length - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap[bc.bitmap.length - 1 - k]=0;
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap[s / 64]=(bc.bitmap[s / 64] << (64 - lastword)) >> (64 - lastword);
  }
  return bc;
}

Fixed version (ground truth):
@Override public Container limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality <= ArrayContainer.DEFAULT_MAX_SIZE) {
    ArrayContainer ac=new ArrayContainer(maxcardinality);
    int pos=0;
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.length); ++k) {
      long bitset=bitmap[k];
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        ac.content[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  BitmapContainer bc=new BitmapContainer(maxcardinality,this.bitmap);
  int s=Util.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.length - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap[bc.bitmap.length - 1 - k]=0;
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap[s / 64]=(bc.bitmap[s / 64] << (64 - lastword)) >> (64 - lastword);
  }
  return bc;
}
Program: 90344
Project: 90344
Buggy source:
@Override public MappeableContainer limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality < MappeableArrayContainer.DEFAULT_MAX_SIZE) {
    MappeableArrayContainer ac=new MappeableArrayContainer(maxcardinality);
    int pos=0;
    short[] cont=ac.content.array();
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.limit()); ++k) {
      long bitset=bitmap.get(k);
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        cont[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  MappeableBitmapContainer bc=new MappeableBitmapContainer(maxcardinality,this.bitmap);
  int s=BufferUtil.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.limit() - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap.put(bc.bitmap.limit() - 1 - k,0);
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap.put(s / 64,(bc.bitmap.get(s / 64) << (64 - lastword)) >> (64 - lastword));
  }
  return bc;
}

Fixed version (ground truth):
@Override public MappeableContainer limit(int maxcardinality){
  if (maxcardinality >= this.cardinality) {
    return clone();
  }
  if (maxcardinality <= MappeableArrayContainer.DEFAULT_MAX_SIZE) {
    MappeableArrayContainer ac=new MappeableArrayContainer(maxcardinality);
    int pos=0;
    short[] cont=ac.content.array();
    for (int k=0; (ac.cardinality < maxcardinality) && (k < bitmap.limit()); ++k) {
      long bitset=bitmap.get(k);
      while ((ac.cardinality < maxcardinality) && (bitset != 0)) {
        long t=bitset & -bitset;
        cont[pos++]=(short)(k * 64 + Long.bitCount(t - 1));
        ac.cardinality++;
        bitset^=t;
      }
    }
    return ac;
  }
  MappeableBitmapContainer bc=new MappeableBitmapContainer(maxcardinality,this.bitmap);
  int s=BufferUtil.toIntUnsigned(select(maxcardinality));
  int usedwords=(s + 63) / 64;
  int todelete=this.bitmap.limit() - usedwords;
  for (int k=0; k < todelete; ++k)   bc.bitmap.put(bc.bitmap.limit() - 1 - k,0);
  int lastword=s % 64;
  if (lastword != 0) {
    bc.bitmap.put(s / 64,(bc.bitmap.get(s / 64) << (64 - lastword)) >> (64 - lastword));
  }
  return bc;
}
Program: 90345
Project: 90345
Buggy source:
/** 
 * Prepares a bitmap for iteration
 * @param r
 */
public void wrap(RoaringBitmap r){
  this.roaringBitmap=r;
  this.hs=0;
  this.pos=(short)(this.roaringBitmap.highLowContainer.size() - 1);
  this.nextContainer();
}

Fixed version (ground truth):
/** 
 * Prepares a bitmap for iteration
 * @param r  bitmap to be iterated over
 */
public void wrap(RoaringBitmap r){
  this.roaringBitmap=r;
  this.hs=0;
  this.pos=(short)(this.roaringBitmap.highLowContainer.size() - 1);
  this.nextContainer();
}
Program: 90346
Project: 90346
Buggy source:
/** 
 * Prepares a bitmap for iteration
 * @param r
 */
public void wrap(ImmutableRoaringBitmap r){
  this.roaringBitmap=r;
  this.hs=0;
  this.pos=(short)(this.roaringBitmap.highLowContainer.size() - 1);
  this.nextContainer();
}

Fixed version (ground truth):
/** 
 * Prepares a bitmap for iteration
 * @param r bitmap to be iterated over
 */
public void wrap(ImmutableRoaringBitmap r){
  this.roaringBitmap=r;
  this.hs=0;
  this.pos=(short)(this.roaringBitmap.highLowContainer.size() - 1);
  this.nextContainer();
}
Program: 90347
Project: 90347
Buggy source:
/** 
 * @return a ContainerPointer to iterator over the array initially positioned at startIndex
 */
MappeableContainerPointer getContainerPointer(int startIndex);

Fixed version (ground truth):
/** 
 * @param startIndex starting index
 * @return a ContainerPointer to iterator over the array initially positioned at startIndex
 */
MappeableContainerPointer getContainerPointer(int startIndex);
Program: 90348
Project: 90348
Buggy source:
private void increaseCapacity(){
  int newCapacity=this.content.length < 64 ? this.content.length * 2 : this.content.length < 1024 ? this.content.length * 3 / 2 : this.content.length * 5 / 4;
  if (newCapacity > ArrayContainer.DEFAULT_MAX_SIZE)   newCapacity=ArrayContainer.DEFAULT_MAX_SIZE;
  this.content=Arrays.copyOf(this.content,newCapacity);
}

Fixed version (ground truth):
private void increaseCapacity(){
  int newCapacity=(this.content.length == 0) ? DEFAULT_INIT_SIZE : this.content.length < 64 ? this.content.length * 2 : this.content.length < 1024 ? this.content.length * 3 / 2 : this.content.length * 5 / 4;
  if (newCapacity > ArrayContainer.DEFAULT_MAX_SIZE)   newCapacity=ArrayContainer.DEFAULT_MAX_SIZE;
  this.content=Arrays.copyOf(this.content,newCapacity);
}
Program: 90349
Project: 90349
Buggy source:
private void increaseCapacity(){
  int newCapacity=this.content.limit() < 64 ? this.content.limit() * 2 : this.content.limit() < 1024 ? this.content.limit() * 3 / 2 : this.content.limit() * 5 / 4;
  if (newCapacity > MappeableArrayContainer.DEFAULT_MAX_SIZE)   newCapacity=MappeableArrayContainer.DEFAULT_MAX_SIZE;
  final ShortBuffer newContent=ShortBuffer.allocate(newCapacity);
  this.content.rewind();
  newContent.put(this.content);
  this.content=newContent;
}

Fixed version (ground truth):
private void increaseCapacity(){
  int newCapacity=(this.content.limit() == 0) ? DEFAULT_INIT_SIZE : this.content.limit() < 64 ? this.content.limit() * 2 : this.content.limit() < 1024 ? this.content.limit() * 3 / 2 : this.content.limit() * 5 / 4;
  if (newCapacity > MappeableArrayContainer.DEFAULT_MAX_SIZE)   newCapacity=MappeableArrayContainer.DEFAULT_MAX_SIZE;
  final ShortBuffer newContent=ShortBuffer.allocate(newCapacity);
  this.content.rewind();
  newContent.put(this.content);
  this.content=newContent;
}
Program: 90350
Project: 90350
Buggy source:
protected static int unsignedBinarySearch(final short[] array,final int begin,final int end,final short k){
  int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array[end - 1]) < ikey))   return -end;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array[middleIndex]);
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}

Fixed version (ground truth):
protected static int unsignedBinarySearch(final short[] array,final int begin,final int end,final short k){
  int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array[end - 1]) < ikey))   return -end - 1;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array[middleIndex]);
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}
Program: 90351
Project: 90351
Buggy source:
protected static int unsignedBinarySearch(final ShortBuffer array,final int begin,final int end,final short k){
  final int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array.get(end - 1)) < ikey))   return -end;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array.get(middleIndex));
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}

Fixed version (ground truth):
protected static int unsignedBinarySearch(final ShortBuffer array,final int begin,final int end,final short k){
  final int ikey=toIntUnsigned(k);
  if ((end > 0) && (toIntUnsigned(array.get(end - 1)) < ikey))   return -end - 1;
  int low=begin;
  int high=end - 1;
  while (low <= high) {
    final int middleIndex=(low + high) >>> 1;
    final int middleValue=toIntUnsigned(array.get(middleIndex));
    if (middleValue < ikey)     low=middleIndex + 1;
 else     if (middleValue > ikey)     high=middleIndex - 1;
 else     return middleIndex;
  }
  return -(low + 1);
}
Program: 90352
Project: 90352
Buggy source:
@Test public void testHorizontalOrCardinality(){
  int[] vals={65535,131071,196607,262143,327679,393215,458751,524287};
  final RoaringBitmap[] b=new RoaringBitmap[2];
  b[0]=RoaringBitmap.bitmapOf(vals);
  b[1]=RoaringBitmap.bitmapOf(vals);
  RoaringBitmap a=FastAggregation.horizontal_or(new Iterator<RoaringBitmap>(){
    int k=0;
    @Override public boolean hasNext(){
      return k < b.length;
    }
    @Override public RoaringBitmap next(){
      return b[k++];
    }
  }
);
  Assert.assertEquals(8,a.getCardinality());
}

Fixed version (ground truth):
@Test public void testHorizontalOrCardinality(){
  int[] vals={65535,131071,196607,262143,327679,393215,458751,524287};
  final RoaringBitmap[] b=new RoaringBitmap[2];
  b[0]=RoaringBitmap.bitmapOf(vals);
  b[1]=RoaringBitmap.bitmapOf(vals);
  RoaringBitmap a=FastAggregation.horizontal_or(new Iterator<RoaringBitmap>(){
    int k=0;
    @Override public boolean hasNext(){
      return k < b.length;
    }
    @Override public void remove(){
    }
    @Override public RoaringBitmap next(){
      return b[k++];
    }
  }
);
  Assert.assertEquals(8,a.getCardinality());
}
Program: 90353
Project: 90353
Buggy source:
@Test public void testHorizontalOrCardinality(){
  int[] vals={65535,131071,196607,262143,327679,393215,458751,524287};
  final MutableRoaringBitmap[] b=new MutableRoaringBitmap[2];
  b[0]=MutableRoaringBitmap.bitmapOf(vals);
  b[1]=MutableRoaringBitmap.bitmapOf(vals);
  MutableRoaringBitmap a=BufferFastAggregation.horizontal_or(new Iterator<ImmutableRoaringBitmap>(){
    int k=0;
    @Override public boolean hasNext(){
      return k < b.length;
    }
    @Override public ImmutableRoaringBitmap next(){
      return b[k++];
    }
  }
);
  Assert.assertEquals(8,a.getCardinality());
}

Fixed version (ground truth):
@Test public void testHorizontalOrCardinality(){
  int[] vals={65535,131071,196607,262143,327679,393215,458751,524287};
  final MutableRoaringBitmap[] b=new MutableRoaringBitmap[2];
  b[0]=MutableRoaringBitmap.bitmapOf(vals);
  b[1]=MutableRoaringBitmap.bitmapOf(vals);
  MutableRoaringBitmap a=BufferFastAggregation.horizontal_or(new Iterator<ImmutableRoaringBitmap>(){
    int k=0;
    @Override public boolean hasNext(){
      return k < b.length;
    }
    @Override public void remove(){
    }
    @Override public ImmutableRoaringBitmap next(){
      return b[k++];
    }
  }
);
  Assert.assertEquals(8,a.getCardinality());
}
Program: 90354
Project: 90354
Buggy source:
/** 
 * Minimizes memory usage while computing the xor aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap horizontal_xor(RoaringBitmap... bitmaps){
  RoaringBitmap answer=new RoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<ContainerPointer> pq=new PriorityQueue<ContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    ContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    ContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    ContainerPointer x2=pq.poll();
    Container newc=x1.getContainer().xor(x2.getContainer());
    while (pq.peek().key() == x1.key()) {
      ContainerPointer x=pq.poll();
      newc=newc.ixor(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}

Fixed version (ground truth):
/** 
 * Minimizes memory usage while computing the xor aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap horizontal_xor(RoaringBitmap... bitmaps){
  RoaringBitmap answer=new RoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<ContainerPointer> pq=new PriorityQueue<ContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    ContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    ContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    ContainerPointer x2=pq.poll();
    Container newc=x1.getContainer().xor(x2.getContainer());
    while (!pq.isEmpty() && (pq.peek().key() == x1.key())) {
      ContainerPointer x=pq.poll();
      newc=newc.ixor(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}
Program: 90355
Project: 90355
Buggy source:
/** 
 * Minimizes memory usage while computing the or aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap horizontal_or(RoaringBitmap... bitmaps){
  RoaringBitmap answer=new RoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<ContainerPointer> pq=new PriorityQueue<ContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    ContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    ContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    ContainerPointer x2=pq.poll();
    Container newc=x1.getContainer().or(x2.getContainer());
    while (pq.peek().key() == x1.key()) {
      ContainerPointer x=pq.poll();
      newc=newc.ior(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}

Fixed version (ground truth):
/** 
 * Minimizes memory usage while computing the or aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static RoaringBitmap horizontal_or(RoaringBitmap... bitmaps){
  RoaringBitmap answer=new RoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<ContainerPointer> pq=new PriorityQueue<ContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    ContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    ContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    ContainerPointer x2=pq.poll();
    Container newc=x1.getContainer().or(x2.getContainer());
    while (!pq.isEmpty() && (pq.peek().key() == x1.key())) {
      ContainerPointer x=pq.poll();
      newc=newc.ior(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}
Program: 90356
Project: 90356
Buggy source:
/** 
 * Minimizes memory usage while computing the xor aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static MappeableRoaringBitmap horizontal_xor(ImmutableRoaringBitmap... bitmaps){
  MappeableRoaringBitmap answer=new MappeableRoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<MappeableContainerPointer> pq=new PriorityQueue<MappeableContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    MappeableContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    MappeableContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    MappeableContainerPointer x2=pq.poll();
    MappeableContainer newc=x1.getContainer().xor(x2.getContainer());
    while (pq.peek().key() == x1.key()) {
      MappeableContainerPointer x=pq.poll();
      newc=newc.ixor(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}

Fixed version (ground truth):
/** 
 * Minimizes memory usage while computing the xor aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static MappeableRoaringBitmap horizontal_xor(ImmutableRoaringBitmap... bitmaps){
  MappeableRoaringBitmap answer=new MappeableRoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<MappeableContainerPointer> pq=new PriorityQueue<MappeableContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    MappeableContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    MappeableContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    MappeableContainerPointer x2=pq.poll();
    MappeableContainer newc=x1.getContainer().xor(x2.getContainer());
    while (!pq.isEmpty() && (pq.peek().key() == x1.key())) {
      MappeableContainerPointer x=pq.poll();
      newc=newc.ixor(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}
Program: 90357
Project: 90357
Buggy source:
/** 
 * Minimizes memory usage while computing the or aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static MappeableRoaringBitmap horizontal_or(ImmutableRoaringBitmap... bitmaps){
  MappeableRoaringBitmap answer=new MappeableRoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<MappeableContainerPointer> pq=new PriorityQueue<MappeableContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    MappeableContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    MappeableContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    MappeableContainerPointer x2=pq.poll();
    MappeableContainer newc=x1.getContainer().or(x2.getContainer());
    while (pq.peek().key() == x1.key()) {
      MappeableContainerPointer x=pq.poll();
      newc=newc.ior(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}

Fixed version (ground truth):
/** 
 * Minimizes memory usage while computing the or aggregate.
 * @param bitmaps input bitmaps
 * @return aggregated bitmap
 */
public static MappeableRoaringBitmap horizontal_or(ImmutableRoaringBitmap... bitmaps){
  MappeableRoaringBitmap answer=new MappeableRoaringBitmap();
  if (bitmaps.length == 0)   return answer;
  PriorityQueue<MappeableContainerPointer> pq=new PriorityQueue<MappeableContainerPointer>(bitmaps.length);
  for (int k=0; k < bitmaps.length; ++k) {
    MappeableContainerPointer x=bitmaps[k].highLowContainer.getContainerPointer();
    if (x.getContainer() != null)     pq.add(x);
  }
  while (!pq.isEmpty()) {
    MappeableContainerPointer x1=pq.poll();
    if (pq.isEmpty() || (pq.peek().key() != x1.key())) {
      answer.highLowContainer.append(x1.key(),x1.getContainer().clone());
      x1.advance();
      if (x1.getContainer() != null)       pq.add(x1);
      continue;
    }
    MappeableContainerPointer x2=pq.poll();
    MappeableContainer newc=x1.getContainer().or(x2.getContainer());
    while (!pq.isEmpty() && (pq.peek().key() == x1.key())) {
      MappeableContainerPointer x=pq.poll();
      newc=newc.ior(x.getContainer());
      x.advance();
      if (x.getContainer() != null)       pq.add(x);
 else       if (pq.isEmpty())       break;
    }
    answer.highLowContainer.append(x1.key(),newc);
    x1.advance();
    if (x1.getContainer() != null)     pq.add(x1);
    x2.advance();
    if (x2.getContainer() != null)     pq.add(x2);
  }
  return answer;
}
Program: 90358
Project: 90358
Buggy source:
@Override public short next(){
  return ArrayContainer.this.content[pos++];
}

Fixed version (ground truth):
@Override public Short next(){
  return new Short(ArrayContainer.this.content[pos++]);
}
Program: 90359
Project: 90359
Buggy source:
@Override public ShortIterator getShortIterator(){
  return new ShortIterator(){
    int pos=0;
    @Override public boolean hasNext(){
      return pos < ArrayContainer.this.cardinality;
    }
    @Override public short next(){
      return ArrayContainer.this.content[pos++];
    }
  }
;
}

Fixed version (ground truth):
@Override public ShortIterator getShortIterator(){
  return new ShortIterator(){
    @Override public boolean hasNext(){
      return pos < ArrayContainer.this.cardinality;
    }
    @Override public short next(){
      return ArrayContainer.this.content[pos++];
    }
    int pos=0;
  }
;
}
Program: 90360
Project: 90360
Buggy source:
@Override public void remove(){
  ArrayContainer.this.remove((short)(pos - 1));
  pos--;
}

Fixed version (ground truth):
@Override public Container remove(final short x){
  final int loc=Util.unsigned_binarySearch(content,0,cardinality,x);
  if (loc >= 0) {
    System.arraycopy(content,loc + 1,content,loc,cardinality - loc - 1);
    --cardinality;
  }
  return this;
}
Program: 90361
Project: 90361
Buggy source:
@Override public Iterator<Short> iterator(){
  return new Iterator<Short>(){
    short pos=0;
    @Override public boolean hasNext(){
      return pos < ArrayContainer.this.cardinality;
    }
    @Override public Short next(){
      return new Short(ArrayContainer.this.content[pos++]);
    }
    @Override public void remove(){
      ArrayContainer.this.remove((short)(pos - 1));
      pos--;
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterator<Short> iterator(){
  return new Iterator<Short>(){
    @Override public boolean hasNext(){
      return pos < ArrayContainer.this.cardinality;
    }
    @Override public Short next(){
      return new Short(ArrayContainer.this.content[pos++]);
    }
    @Override public void remove(){
      ArrayContainer.this.remove((short)(pos - 1));
      pos--;
    }
    short pos=0;
  }
;
}
Program: 90362
Project: 90362
Buggy source:
public ArrayContainer(){
  this(DEFAULTINITSIZE);
}

Fixed version (ground truth):
public ArrayContainer(final int capacity){
  content=new short[capacity];
}
Program: 90363
Project: 90363
Buggy source:
/** 
 * running time is in O(n) time if insert is not in order.
 */
@Override public Container add(final short x){
  if ((cardinality == 0) || (Util.toIntUnsigned(x) > Util.toIntUnsigned(content[cardinality - 1]))) {
    if (cardinality >= DEFAULTMAXSIZE) {
      BitmapContainer a=ContainerFactory.transformToBitmapContainer(this);
      a.add(x);
      return a;
    }
    if (cardinality >= this.content.length)     increaseCapacity();
    content[cardinality++]=x;
    return this;
  }
  int loc=Util.unsigned_binarySearch(content,0,cardinality,x);
  if (loc < 0) {
    if (cardinality >= DEFAULTMAXSIZE) {
      BitmapContainer a=ContainerFactory.transformToBitmapContainer(this);
      a.add(x);
      return a;
    }
    if (cardinality >= this.content.length)     increaseCapacity();
    System.arraycopy(content,-loc - 1,content,-loc,cardinality + loc + 1);
    content[-loc - 1]=x;
    ++cardinality;
  }
  return this;
}

Fixed version (ground truth):
/** 
 * running time is in O(n) time if insert is not in order.
 */
@Override public Container add(final short x){
  if (cardinality >= DEFAULTMAXSIZE) {
    BitmapContainer a=ContainerFactory.transformToBitmapContainer(this);
    a.add(x);
    return a;
  }
  if ((cardinality == 0) || (Util.toIntUnsigned(x) > Util.toIntUnsigned(content[cardinality - 1]))) {
    if (cardinality >= this.content.length)     increaseCapacity();
    content[cardinality++]=x;
    return this;
  }
  int loc=Util.unsigned_binarySearch(content,0,cardinality,x);
  if (loc < 0) {
    if (cardinality >= this.content.length)     increaseCapacity();
    System.arraycopy(content,-loc - 1,content,-loc,cardinality + loc + 1);
    content[-loc - 1]=x;
    ++cardinality;
  }
  return this;
}
Program: 90364
Project: 90364
Buggy source:
@Override public short next(){
  short j=(short)i;
  i=BitmapContainer.this.nextSetBit(i + 1);
  return j;
}

Fixed version (ground truth):
@Override public Short next(){
  j=i;
  i=BitmapContainer.this.nextSetBit(i + 1);
  return new Short((short)j);
}
Program: 90365
Project: 90365
Buggy source:
@Override public ShortIterator getShortIterator(){
  return new ShortIterator(){
    int i=BitmapContainer.this.nextSetBit(0);
    @Override public boolean hasNext(){
      return i >= 0;
    }
    @Override public short next(){
      short j=(short)i;
      i=BitmapContainer.this.nextSetBit(i + 1);
      return j;
    }
  }
;
}

Fixed version (ground truth):
@Override public ShortIterator getShortIterator(){
  return new ShortIterator(){
    @Override public boolean hasNext(){
      return i >= 0;
    }
    @Override public short next(){
      short j=(short)i;
      i=BitmapContainer.this.nextSetBit(i + 1);
      return j;
    }
    int i=BitmapContainer.this.nextSetBit(0);
  }
;
}
Program: 90366
Project: 90366
Buggy source:
@Override public void remove(){
  BitmapContainer.this.remove((short)j);
}

Fixed version (ground truth):
@Override public Container remove(final short i){
  final int x=Util.toIntUnsigned(i);
  if (cardinality == ArrayContainer.DEFAULTMAXSIZE) {
    if ((bitmap[x / 64] & (1l << x)) != 0) {
      --cardinality;
      bitmap[x / 64]&=~(1l << x);
      return ContainerFactory.transformToArrayContainer(this);
    }
  }
  cardinality-=(bitmap[x / 64] & (1l << x)) >>> x;
  bitmap[x / 64]&=~(1l << x);
  return this;
}
Program: 90367
Project: 90367
Buggy source:
@Override public Iterator<Short> iterator(){
  return new Iterator<Short>(){
    int i=BitmapContainer.this.nextSetBit(0);
    int j;
    @Override public boolean hasNext(){
      return i >= 0;
    }
    @Override public Short next(){
      j=i;
      i=BitmapContainer.this.nextSetBit(i + 1);
      return new Short((short)j);
    }
    @Override public void remove(){
      BitmapContainer.this.remove((short)j);
    }
  }
;
}

Fixed version (ground truth):
@Override public Iterator<Short> iterator(){
  return new Iterator<Short>(){
    @Override public boolean hasNext(){
      return i >= 0;
    }
    @Override public Short next(){
      j=i;
      i=BitmapContainer.this.nextSetBit(i + 1);
      return new Short((short)j);
    }
    @Override public void remove(){
      BitmapContainer.this.remove((short)j);
    }
    int i=BitmapContainer.this.nextSetBit(0);
    int j;
  }
;
}
Program: 90368
Project: 90368
Buggy source:
public BitmapContainer inPlaceOR(final ArrayContainer value2){
  for (int k=0; k < value2.cardinality; ++k) {
    final int i=Util.toIntUnsigned(value2.content[k]) >>> 6;
    this.cardinality+=((~this.bitmap[i]) & (1l << value2.content[k])) >>> value2.content[k];
    this.bitmap[i]|=(1l << value2.content[k]);
  }
  return this;
}

Fixed version (ground truth):
public Container inPlaceOR(final BitmapContainer B2){
  this.cardinality=0;
  for (int k=0; k < this.bitmap.length; k++) {
    this.bitmap[k]|=B2.bitmap[k];
    this.cardinality+=Long.bitCount(this.bitmap[k]);
  }
  return this;
}
Program: 90369
Project: 90369
Buggy source:
public ArrayContainer and(final ArrayContainer value2){
  final ArrayContainer answer=ContainerFactory.getArrayContainer();
  if (answer.content.length < value2.content.length)   answer.content=new short[value2.content.length];
  for (int k=0; k < value2.getCardinality(); ++k)   if (this.contains(value2.content[k]))   answer.content[answer.cardinality++]=value2.content[k];
  return answer;
}

Fixed version (ground truth):
public Container and(final BitmapContainer value2){
  final BitmapContainer answer=ContainerFactory.getUnintializedBitmapContainer();
  answer.cardinality=0;
  for (int k=0; k < answer.bitmap.length; ++k) {
    answer.bitmap[k]=this.bitmap[k] & value2.bitmap[k];
    answer.cardinality+=Long.bitCount(answer.bitmap[k]);
  }
  if (answer.cardinality <= ArrayContainer.DEFAULTMAXSIZE)   return ContainerFactory.transformToArrayContainer(answer);
  return answer;
}
Program: 90370
Project: 90370
Buggy source:
@Override public Container add(final short i){
  final int x=Util.toIntUnsigned(i);
  final long previous=bitmap[x / 64];
  if (previous != (bitmap[x / 64]|=(1l << x)))   ++cardinality;
  return this;
}

Fixed version (ground truth):
@Override public Container add(final short i){
  final int x=Util.toIntUnsigned(i);
  final long previous=bitmap[x / 64];
  bitmap[x / 64]|=(1l << x);
  cardinality+=(previous ^ bitmap[x / 64]) >>> x;
  return this;
}
Program: 90371
Project: 90371
Buggy source:
public Container inPlaceXOR(final ArrayContainer value2){
  for (int k=0; k < value2.getCardinality(); ++k) {
    final int index=Util.toIntUnsigned(value2.content[k]) >>> 6;
    this.cardinality+=1 - 2 * ((this.bitmap[index] & (1l << value2.content[k])) >>> value2.content[k]);
    this.bitmap[index]^=(1l << value2.content[k]);
  }
  if (this.cardinality <= ArrayContainer.DEFAULTMAXSIZE)   return ContainerFactory.transformToArrayContainer(this);
  return this;
}

Fixed version (ground truth):
public Container inPlaceXOR(BitmapContainer B2){
  this.cardinality=0;
  for (int k=0; k < this.bitmap.length; ++k) {
    this.bitmap[k]^=B2.bitmap[k];
    this.cardinality+=Long.bitCount(this.bitmap[k]);
  }
  if (this.cardinality <= ArrayContainer.DEFAULTMAXSIZE)   return ContainerFactory.transformToArrayContainer(this);
  return this;
}
Program: 90372
Project: 90372
Buggy source:
public Container andNot(final ArrayContainer value2){
  final BitmapContainer answer=ContainerFactory.getCopyOfBitmapContainer(this);
  for (int k=0; k < value2.cardinality; ++k) {
    final int i=Util.toIntUnsigned(value2.content[k]) >>> 6;
    answer.bitmap[i]=answer.bitmap[i] & (~(1l << value2.content[k]));
    answer.cardinality-=(answer.bitmap[i] ^ this.bitmap[i]) >>> value2.content[k];
  }
  if (answer.cardinality <= ArrayContainer.DEFAULTMAXSIZE)   return ContainerFactory.transformToArrayContainer(answer);
  return answer;
}

Fixed version (ground truth):
public Container andNot(final BitmapContainer value2){
  final BitmapContainer answer=ContainerFactory.getUnintializedBitmapContainer();
  answer.cardinality=0;
  for (int k=0; k < answer.bitmap.length; ++k) {
    answer.bitmap[k]=this.bitmap[k] & (~value2.bitmap[k]);
    answer.cardinality+=Long.bitCount(answer.bitmap[k]);
  }
  if (answer.cardinality <= ArrayContainer.DEFAULTMAXSIZE)   return ContainerFactory.transformToArrayContainer(answer);
  return answer;
}
Program: 90373
Project: 90373
Buggy source:
public void extendArray(){
  if (this.nbKeys == this.array.length) {
    int newcapacity;
    if (this.array.length < 4) {
      newcapacity=4;
    }
 else     if (this.array.length < 1024) {
      newcapacity=2 * this.array.length;
    }
 else {
      newcapacity=5 * this.array.length / 4;
    }
    this.array=Arrays.copyOf(this.array,newcapacity);
  }
}

Fixed version (ground truth):
public void extendArray(int k){
  if (this.size + k >= this.array.length) {
    int newcapacity;
    if (this.array.length < 4) {
      newcapacity=this.size + k;
    }
 else     if (this.array.length < 1024) {
      newcapacity=2 * (this.size + k);
    }
 else {
      newcapacity=5 * (this.size + k) / 4;
    }
    this.array=Arrays.copyOf(this.array,newcapacity);
  }
}
Program: 90374
Project: 90374
Buggy source:
public int getIndex(short x){
  return this.binarySearch(0,nbKeys,x);
}

Fixed version (ground truth):
public int getIndex(short x){
  return this.binarySearch(0,size,x);
}
Program: 90375
Project: 90375
Buggy source:
public Container getContainer(short x){
  int i=this.binarySearch(0,nbKeys,x);
  if (i < 0)   return null;
  return this.array[i].value;
}

Fixed version (ground truth):
public Container getContainer(short x){
  int i=this.binarySearch(0,size,x);
  if (i < 0)   return null;
  return this.array[i].value;
}