src/main/java/com/googlecode/javaewah/FastAggregation.java
public static EWAHCompressedBitmap or(final Iterator<EWAHCompressedBitmap> bitmaps) {
        PriorityQueue<EWAHCompressedBitmap> pq = new PriorityQueue<EWAHCompressedBitmap>(32,
                new Comparator<EWAHCompressedBitmap>() {
                    @Override
                    public int compare(EWAHCompressedBitmap a, EWAHCompressedBitmap b) {
                        return a.sizeInBytes()
                                - b.sizeInBytes();
                    }
                }
        );
        while(bitmaps.hasNext())
            pq.add(bitmaps.next());
        if(pq.isEmpty()) return new EWAHCompressedBitmap();
        while (pq.size() > 1) {
            EWAHCompressedBitmap x1 = pq.poll();
            EWAHCompressedBitmap x2 = pq.poll();
            pq.add(x1.or(x2));
        }
        return pq.poll();
    }
public static EWAHCompressedBitmap or(final Iterator<EWAHCompressedBitmap> bitmaps) {
        PriorityQueue<EWAHCompressedBitmap> pq = new PriorityQueue<EWAHCompressedBitmap>(32,
                new Comparator<EWAHCompressedBitmap>() {
                    @Override
                    public int compare(EWAHCompressedBitmap a, EWAHCompressedBitmap b) {
                        return a.sizeInBytes()
                                - b.sizeInBytes();
                    }
                }
        );
        while(bitmaps.hasNext())
            pq.add(bitmaps.next());
        if(pq.isEmpty()) return new EWAHCompressedBitmap();
        while (pq.size() > 1) {
            EWAHCompressedBitmap x1 = pq.poll();
            EWAHCompressedBitmap x2 = pq.poll();
            pq.add(x1.or(x2));
        }
        return pq.poll();
    }
Simple algorithm that computes the OR aggregate.

@param bitmaps input bitmaps
@return new bitmap containing the aggregate