
com.googlecode.javaewah32.BitCounter32 Maven / Gradle / Ivy
package com.googlecode.javaewah32;
/*
* Copyright 2009-2013, Daniel Lemire, Cliff Moon, David McIntosh, Robert Becho, Google Inc. and Veronika Zenz
* Licensed under the Apache License, Version 2.0.
*/
/**
* BitCounter is a fake bitset data structure. Instead of storing the actual data,
* it only records the number of set bits.
*
* @since 0.5.0
* @author Daniel Lemire and David McIntosh
*/
public final class BitCounter32 implements BitmapStorage32 {
/**
* Virtually add words directly to the bitmap
*
* @param newdata the word
*/
// @Override : causes problems with Java 1.5
@Override
public void add(final int newdata) {
this.oneBits += Integer.bitCount(newdata);
}
/**
* virtually add several literal words.
*
* @param data the literal words
* @param start the starting point in the array
* @param number the number of literal words to add
*/
// @Override : causes problems with Java 1.5
@Override
public void addStreamOfLiteralWords(int[] data, int start, int number) {
for(int i=start;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy