lemire/javaewah — pull request #11 by mctofu (2012-03-03 20:20:25+00:00)
Title: a few efficiency additions

Here are a few changes you may find useful.

1) slight tweak to serialization to use the actualsizeinwords to set the buffer size when deserializing so it doesn't allocate more memory than it really needs.
2) added an orCardinality method that is a shortcut for bitmap1.or(bitmap2).cardinality() but doesn't need to create an intermediate bitmap.
3) added static or and orCardinality methods that can handle N number of bitmaps. For example, bitmap1.or(bitmap2).or(bitmap3) could be done as EWAHCompressedBitmap.or(bitmap1, bitmap2, bitmap3). It can be slower when N is small but avoids having to create N-2 intermediate bitmaps.
4) I found that Long.bitCount performed much faster when counting bits in the cardinality() method.