public static SparseBitmap and ( SparseBitmap ... bitmaps ) { if ( bitmaps . length == 0 ) return new SparseBitmap ( ) ; else if ( bitmaps . length == 1 ) return bitmaps [ 0 ] ; else if ( bitmaps . length == 2 ) return bitmaps [ 0 ] . and ( bitmaps [ 1 ] ) ; // for "and" a priority queue is not needed, but // overhead ought to be small PriorityQueue < SparseBitmap > pq = new PriorityQueue < SparseBitmap > ( bitmaps . length , smallfirst ) ; for ( SparseBitmap x : bitmaps ) pq . ( x ) ; while ( pq . size ( ) > 1 ) { SparseBitmap x1 = pq . poll ( ) ; SparseBitmap x2 = pq . poll ( ) ; pq . add ( x1 . and ( x2 ) ) ; } return pq . poll ( ) ; }
Computes the bit - wise and aggregate over several bitmaps .