Uses a priority queue to compute the or aggregate.

This function runs in linearithmic (O(n log n)) time with respect to the number of bitmaps.

@param bitmaps input bitmaps
@return aggregated bitmap
@see #horizontal_or(ImmutableRoaringBitmap...)
349979
public static MutableRoaringBitmap priorityqueue_or(
      @SuppressWarnings("rawtypes") Iterator bitmaps) {
    if (!bitmaps.hasNext()) {
      return new MutableRoaringBitmap();
    }
    // we buffer the call to getLongSizeInBytes(), hence the code complexity
    ArrayList<ImmutableRoaringBitmap> buffer = new ArrayList<>();
    while (bitmaps.hasNext()) {
      buffer.add((ImmutableRoaringBitmap) bitmaps.next());
    }
    final long[] sizes = new long[buffer.size()];
    final boolean[] istmp = new boolean[buffer.size()];
    for (int k = 0; k < sizes.length; ++k) {
      sizes[k] = buffer.get(k).getLongSizeInBytes();
    }
    PriorityQueue<Integer> pq = new PriorityQueue<>(128, new Comparator<Integer>() {
      @Override
      public int compare(Integer a, Integer b) {
        return (int)(sizes[a] - sizes[b]);
      }
    });
    for (int k = 0; k < sizes.length; ++k) {
      pq.add(k);
    }
    if (pq.size() == 1) {
      return buffer.get(pq.poll()).toMutableRoaringBitmap();
    }
    while (pq.size() > 1) {
      Integer x1 = pq.poll();
      Integer x2 = pq.poll();
      if (istmp[x1] && istmp[x2]) {
        buffer.set(x1, MutableRoaringBitmap.lazyorfromlazyinputs(
            (MutableRoaringBitmap) buffer.get(x1), (MutableRoaringBitmap) buffer.get(x2)));
        sizes[x1] = buffer.get(x1).getLongSizeInBytes();
        pq.add(x1);
      } else if (istmp[x2]) {
        ((MutableRoaringBitmap) buffer.get(x2)).lazyor(buffer.get(x1));
        sizes[x2] = buffer.get(x2).getLongSizeInBytes();
        pq.add(x2);
      } else if (istmp[x1]) {
        ((MutableRoaringBitmap) buffer.get(x1)).lazyor(buffer.get(x2));
        sizes[x1] = buffer.get(x1).getLongSizeInBytes();
        pq.add(x1);
      } else {
        buffer.set(x1, ImmutableRoaringBitmap.lazyor(buffer.get(x1), buffer.get(x2)));
        sizes[x1] = buffer.get(x1).getLongSizeInBytes();
        istmp[x1] = true;
        pq.add(x1);
      }
    }
    MutableRoaringBitmap answer = (MutableRoaringBitmap) buffer.get(pq.poll());
    answer.repairAfterLazy();
    return answer;
  }
482981
public static void fillArrayANDNOT(final short[] container, final long[] bitmap1,
      final long[] bitmap2) {
    int pos = 0;
    if (bitmap1.length != bitmap2.length) {
      throw new IllegalArgumentException("not supported");
    }
    for (int k = 0; k < bitmap1.length; ++k) {
      long bitset = bitmap1[k] & (~bitmap2[k]);
      while (bitset != 0) {
        container[pos++] = (short) (k * 64 + numberOfTrailingZeros(bitset));
        bitset &= (bitset - 1);
      }
    }
  }
959147
public static void or2by2(BitmapContainer container, SparseBitmap bitmap1,
			SparseBitmap bitmap2) {
		int it1 = 0;
		int it2 = 0;
		int p1 = bitmap1.buffer.get(it1);
		int p2 = bitmap2.buffer.get(it2);
		if ((it1 < bitmap1.buffer.size()) && (it2 < bitmap2.buffer.size()))
			while (true) {
				if (p1 < p2) {
					container.add(bitmap1.buffer.get(it1 + 1), p1);
					it1 += 2;
					if (it1 >= bitmap1.buffer.size())
						break;
					p1 += bitmap1.buffer.get(it1) + 1;
				} else if (p1 > p2) {
					container.add(bitmap2.buffer.get(it2 + 1), p2);
					it2 += 2;
					if (it2 >= bitmap2.buffer.size())
						break;
					p2 += bitmap2.buffer.get(it2) + 1;
				} else {
					container.add(
							bitmap1.buffer.get(it1 + 1)
									| bitmap2.buffer.get(it2 + 1), p1);
					it1 += 2;
					it2 += 2;
					if (it1 < bitmap1.buffer.size())
						p1 += bitmap1.buffer.get(it1) + 1;
					if (it2 < bitmap2.buffer.size())
						p2 += bitmap2.buffer.get(it2) + 1;
					if ((it1 >= bitmap1.buffer.size())
							|| (it2 >= bitmap2.buffer.size()))
						break;
				}
			}

		if (it1 < bitmap1.buffer.size()) {
			while (true) {
				container.add(bitmap1.buffer.get(it1 + 1), p1);
				it1 += 2;
				if (it1 == bitmap1.buffer.size())
					break;
				p1 += bitmap1.buffer.get(it1) + 1;
			}
		}
		if (it2 < bitmap2.buffer.size()) {
			while (true) {
				container.add(bitmap2.buffer.get(it2 + 1), p2);
				it2 += 2;
				if (it2 == bitmap2.buffer.size())
					break;
				p2 += bitmap2.buffer.get(it2) + 1;
			}
		}
	}
1081451
public static RoaringBitmap naive_and(RoaringBitmap... bitmaps) {
    if (bitmaps.length == 0) {
      return new RoaringBitmap();
    }
    RoaringBitmap answer = bitmaps[0].clone();
    for (int k = 1; k < bitmaps.length; ++k) {
      answer.and(bitmaps[k]);
    }
    return answer;
  }
533638
@Deprecated
  public static int flipBitmapRangeAndCardinalityChange(LongBuffer bitmap, int start, int end) {
    if (BufferUtil.isBackedBySimpleArray(bitmap)) {
      return Util.flipBitmapRangeAndCardinalityChange(bitmap.array(), start, end);
    }
    int cardbefore = cardinalityInBitmapWordRange(bitmap, start, end);
    flipBitmapRange(bitmap, start, end);
    int cardafter = cardinalityInBitmapWordRange(bitmap, start, end);
    return cardafter - cardbefore;
  }
1312770
public SparseBitmap or(SparseBitmap o) {
		SparseBitmap a = new SparseBitmap();
		or2by2(a, this, o);
		return a;
	}
1282430
public static SkippableIterator flatand(SkippableIterator... bitmap) {
		if (bitmap.length == 0)
			throw new RuntimeException("nothing to process");
		SkippableIterator answer = bitmap[0];
		for (int k = 1; k < bitmap.length; ++k) {
			answer = and2by2(answer, bitmap[k]);
		}
		return answer;
	}
1082986
private static Bitmap checkSource(Bitmap original, int radius) {
        if (radius < 0 || radius > 256) {
            throw new RuntimeException("Blur bitmap radius must >= 1 and <=256.");
        }

        // First we should check the original
        if (original == null) {
            throw new NullPointerException("Blur bitmap original isn't null.");
        }
        if (original.isRecycled()) {
            throw new RuntimeException("Blur bitmap can't blur a recycled bitmap.");
        }

        Bitmap.Config config = original.getConfig();
        if (config != Bitmap.Config.ARGB_8888 && config != Bitmap.Config.RGB_565) {
            throw new RuntimeException("Blur bitmap only supported Bitmap.Config.ARGB_8888 and Bitmap.Config.RGB_565.");
        }

        return (original);
    }
1226171
public static RoaringBitmap priorityqueue_xor(RoaringBitmap... bitmaps) {
    // TODO: This code could be faster, see priorityqueue_or
    if (bitmaps.length == 0) {
      return new RoaringBitmap();
    }

    PriorityQueue<RoaringBitmap> pq =
        new PriorityQueue<>(bitmaps.length, new Comparator<RoaringBitmap>() {
          @Override
          public int compare(RoaringBitmap a, RoaringBitmap b) {
            return (int)(a.getLongSizeInBytes() - b.getLongSizeInBytes());
          }
        });
    Collections.addAll(pq, bitmaps);
    while (pq.size() > 1) {
      RoaringBitmap x1 = pq.poll();
      RoaringBitmap x2 = pq.poll();
      pq.add(RoaringBitmap.xor(x1, x2));
    }
    return pq.poll();
  }
81271
private static Iterator<RoaringBitmap> selectRangeWithoutCopy(final 
      Iterator<? extends RoaringBitmap> bitmaps,
      final long rangeStart, final long rangeEnd) {
    Iterator<RoaringBitmap> bitmapsIterator;
    bitmapsIterator = new Iterator<RoaringBitmap>() {
      @Override
      public boolean hasNext() {
        return bitmaps.hasNext();
      }

      @Override
      public RoaringBitmap next() {
        RoaringBitmap next = bitmaps.next();
        return selectRangeWithoutCopy(next, rangeStart, rangeEnd);
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException("Remove not supported");
      }
    };
    return bitmapsIterator;
  }
1283410
public static RoaringBitmap naive_or(Iterator<? extends RoaringBitmap> bitmaps) {
    RoaringBitmap answer = new RoaringBitmap();
    while (bitmaps.hasNext()) {
      answer.naivelazyor(bitmaps.next());
    }
    answer.repairAfterLazy();
    return answer;
  }
1003879
public CallbackResult<V> processCallbacks(Object... params)
	{
		if (callbacks.size() == 0)
			return CallbackResult.noResult();

		CallbackResult<V> result = CallbackResult.noResult();
		Priority lastPriority = Priority.HIGHEST;
		for (Pair<C, CallbackOption<P>> pair : callbacks)
		{
			if (result.isCancelled() && pair.getRight().getPriority() != lastPriority)
				return result;

			if (pair.getRight().apply(params))
			{
				CallbackResult<V> tmp = pair.getLeft().call(params);
				result = reduce.apply(result, tmp);
				if (result.isForcedCancelled())
					return result;

				lastPriority = pair.getRight().getPriority();
			}
		}

		return result;
	}
1011363
public static BitmapDescriptor vectorToBitmap(@DrawableRes int drawableRes, @ColorRes int colorRes) {
		Drawable vectorDrawable = VectorDrawableCompat.create(AbstractApplication.get().getResources(), drawableRes, null);
		Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
		Canvas canvas = new Canvas(bitmap);
		vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
		DrawableCompat.setTint(vectorDrawable, AbstractApplication.get().getResources().getColor(colorRes));
		vectorDrawable.draw(canvas);
		return BitmapDescriptorFactory.fromBitmap(bitmap);
	}
658183
public static MutableRoaringBitmap bitmapOf(final long[] words) {
    // split long[] into blocks.
    // each block becomes a single container, if any bit is set
    final MutableRoaringBitmap ans = new MutableRoaringBitmap();
    int containerIndex = 0;
    for (int from = 0; from < words.length; from += BLOCK_LENGTH) {
      final int to = Math.min(from + BLOCK_LENGTH, words.length);
      final int blockCardinality = cardinality(from, to, words);
      if (blockCardinality > 0) {
        ((MutableRoaringArray) ans.highLowContainer).insertNewKeyValueAt(containerIndex++,
            BufferUtil.highbits(from * Long.SIZE),
            BufferBitSetUtil.containerOf(from, to, blockCardinality, words));
      }
    }
    return ans;
  }
100232
private MappeableContainer convertToLazyBitmapIfNeeded() {
    // when nbrruns exceed MappeableArrayContainer.DEFAULT_MAX_SIZE, then we know it should be
    // stored as a bitmap, always
    if (this.nbrruns > MappeableArrayContainer.DEFAULT_MAX_SIZE) {
      MappeableBitmapContainer answer = new MappeableBitmapContainer();
      for (int rlepos = 0; rlepos < this.nbrruns; ++rlepos) {
        int start = toIntUnsigned(this.getValue(rlepos));
        int end = start + toIntUnsigned(this.getLength(rlepos)) + 1;
        BufferUtil.setBitmapRange(answer.bitmap, start, end);
      }
      answer.cardinality = -1;
      return answer;
    }
    return this;
  }
321868
public static MutableRoaringBitmap naive_or(@SuppressWarnings("rawtypes") Iterator bitmaps) {
    MutableRoaringBitmap answer = new MutableRoaringBitmap();
    while (bitmaps.hasNext()) {
      answer.naivelazyor((ImmutableRoaringBitmap) bitmaps.next());
    }
    answer.repairAfterLazy();
    return answer;
  }
492382
public static int bitmapSize(Bitmap bitmap) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return bitmap.getByteCount();
        } else {
            return bitmap.getRowBytes() * bitmap.getHeight();
        }
    }