Java Code Examples for java.util.Arrays#fill()

The following examples show how to use java.util.Arrays#fill() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashGeneratorUtil.java    From sunbird-lms-service with MIT License 6 votes vote down vote up
private static List<Integer> getPrimes() {
  List<Integer> list = new ArrayList<>();
  boolean prime[] = new boolean[MAX_NUMBER + 1];
  Arrays.fill(prime, true);
  for (int p = 2; p * p <= MAX_NUMBER; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= MAX_NUMBER; i += p) prime[i] = false;
    }
  }
  for (int i = numPrimes; i <= MAX_NUMBER; i++) {
    if (prime[i] == true) {
      list.add(i);
    }
  }
  return list;
}
 
Example 2
Source File: SeededTestData.java    From RoaringBitmap with Apache License 2.0 6 votes vote down vote up
private static int[] createSorted16BitInts(int howMany, SplittableRandom random) {
  // we can have at most 65536 keys in a RoaringBitmap
  long[] bitset = bits.get();
  Arrays.fill(bitset, 0L);
  int consumed = 0;
  while (consumed < howMany) {
    int value = random.nextInt(1 << 16);
    long bit = (1L << value);
    consumed += 1 - Long.bitCount(bitset[value >>> 6] & bit);
    bitset[value >>> 6] |= bit;
  }
  int[] keys = new int[howMany];
  int prefix = 0;
  int k = 0;
  for (int i = bitset.length - 1; i >= 0; --i) {
    long word = bitset[i];
    while (word != 0) {
      keys[k++] = prefix + Long.numberOfTrailingZeros(word);
      word &= (word - 1);
    }
    prefix += 64;
  }
  return keys;
}
 
Example 3
Source File: QualityScorePreservation.java    From cramtools with Apache License 2.0 6 votes vote down vote up
public void addQualityScores(final SAMRecord s, final CramCompressionRecord r, final ReferenceTracks t) {
	if (s.getBaseQualities() == SAMRecord.NULL_QUALS) {
		r.qualityScores = SAMRecord.NULL_QUALS;
		r.setForcePreserveQualityScores(false);
		return;
	}

	final byte[] scores = new byte[s.getReadLength()];
	Arrays.fill(scores, (byte) -1);
	for (final PreservationPolicy p : policyList)
		addQS(s, r, scores, t, p);

	if (!r.isForcePreserveQualityScores()) {
		for (int i = 0; i < scores.length; i++) {
			if (scores[i] > -1) {
				if (r.readFeatures == null || r.readFeatures == Collections.EMPTY_LIST)
					r.readFeatures = new LinkedList<ReadFeature>();

				r.readFeatures.add(new BaseQualityScore(i + 1, scores[i]));
			}
		}
		if (r.readFeatures != null)
			Collections.sort(r.readFeatures, readFeaturePositionComparator);
	}
	r.qualityScores = scores;
}
 
Example 4
Source File: ArrayFillFunction.java    From phoenix with Apache License 2.0 6 votes vote down vote up
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
    if (!getElementExpr().evaluate(tuple, ptr)) {
        return false;
    }
    Object element = getElementExpr().getDataType().toObject(ptr, getElementExpr().getSortOrder(), getElementExpr().getMaxLength(), getElementExpr().getScale());
    if (!getLengthExpr().evaluate(tuple, ptr) || ptr.getLength() == 0) {
        return false;
    }
    int length = (Integer) getLengthExpr().getDataType().toObject(ptr, getLengthExpr().getSortOrder(), getLengthExpr().getMaxLength(), getLengthExpr().getScale());
    if (length <= 0) {
        throw new IllegalArgumentException("Array length should be greater than 0");
    }
    Object[] elements = new Object[length];
    Arrays.fill(elements, element);
    PhoenixArray array = PDataType.instantiatePhoenixArray(getElementExpr().getDataType(), elements);
    //When max length of a char array is not the max length of the element passed in
    if (getElementExpr().getDataType().isFixedWidth() && getMaxLength() != null && getMaxLength() != array.getMaxLength()) {
        array = new PhoenixArray(array, getMaxLength());
    }
    ptr.set(((PArrayDataType) getDataType()).toBytes(array, getElementExpr().getDataType(), getElementExpr().getSortOrder()));
    return true;
}
 
Example 5
Source File: BlobCache.java    From medialibrary with Apache License 2.0 5 votes vote down vote up
public void clearEntry(long key) throws IOException {
    if (!lookupInternal(key, mActiveHashStart)) {
        return; // Nothing to clear
    }
    byte[] header = mBlobHeader;
    Arrays.fill(header, (byte) 0);
    mActiveDataFile.seek(mFileOffset);
    mActiveDataFile.write(header);
}
 
Example 6
Source File: CredentialProviderUtility.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves a password from the command line.
 * @param textDevice  the system console.
 * @param key   the password key/alias.
 * @return the password.
 */
private static char[] getPassword(TextDevice textDevice, String key) {
    boolean noMatch;
    char[] cred = new char[0];
    char[] passwd1;
    char[] passwd2;
    do {
        passwd1 = textDevice.readPassword("Please enter the password value for %s:", key);
        passwd2 = textDevice.readPassword("Please enter the password value for %s again:", key);
        noMatch = !Arrays.equals(passwd1, passwd2);
        if (noMatch) {
            if (passwd1 != null) {
                Arrays.fill(passwd1, ' ');
            }
            textDevice.printf("Password entries don't match. Please try again.\n");
        } else {
            if (passwd1.length == 0) {
                textDevice.printf("An empty password is not valid.  Please try again.\n");
                noMatch = true;
            } else {
                cred = passwd1;
            }
        }
        if (passwd2 != null) {
            Arrays.fill(passwd2, ' ');
        }
    } while (noMatch);
    return cred;
}
 
Example 7
Source File: HmacCore.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the HMAC with the given secret key and algorithm parameters.
 *
 * @param key the secret key.
 * @param params the algorithm parameters.
 *
 * @exception InvalidKeyException if the given key is inappropriate for
 * initializing this MAC.
 * @exception InvalidAlgorithmParameterException if the given algorithm
 * parameters are inappropriate for this MAC.
 */
protected void engineInit(Key key, AlgorithmParameterSpec params)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params != null) {
        throw new InvalidAlgorithmParameterException
            ("HMAC does not use parameters");
    }

    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("Secret key expected");
    }

    byte[] secret = key.getEncoded();
    if (secret == null) {
        throw new InvalidKeyException("Missing key data");
    }

    // if key is longer than the block length, reset it using
    // the message digest object.
    if (secret.length > blockLen) {
        byte[] tmp = md.digest(secret);
        // now erase the secret
        Arrays.fill(secret, (byte)0);
        secret = tmp;
    }

    // XOR k with ipad and opad, respectively
    for (int i = 0; i < blockLen; i++) {
        int si = (i < secret.length) ? secret[i] : 0;
        k_ipad[i] = (byte)(si ^ 0x36);
        k_opad[i] = (byte)(si ^ 0x5c);
    }

    // now erase the secret
    Arrays.fill(secret, (byte)0);
    secret = null;

    engineReset();
}
 
Example 8
Source File: NordsieckStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void computeInterpolatedStateAndDerivatives(final double theta, final double oneMinusThetaH) {

    final double x = interpolatedTime - referenceTime;
    final double normalizedAbscissa = x / scalingH;

    Arrays.fill(stateVariation, 0.0);
    Arrays.fill(interpolatedDerivatives, 0.0);

    // apply Taylor formula from high order to low order,
    // for the sake of numerical accuracy
    final double[][] nData = nordsieck.getDataRef();
    for (int i = nData.length - 1; i >= 0; --i) {
        final int order = i + 2;
        final double[] nDataI = nData[i];
        final double power = FastMath.pow(normalizedAbscissa, order);
        for (int j = 0; j < nDataI.length; ++j) {
            final double d = nDataI[j] * power;
            stateVariation[j]          += d;
            interpolatedDerivatives[j] += order * d;
        }
    }

    for (int j = 0; j < currentState.length; ++j) {
        stateVariation[j] += scaled[j] * normalizedAbscissa;
        interpolatedState[j] = currentState[j] + stateVariation[j];
        interpolatedDerivatives[j] =
            (interpolatedDerivatives[j] + scaled[j] * normalizedAbscissa) / x;
    }

}
 
Example 9
Source File: Cardumen_00105_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * @param n Number of rows.
 * @param m Number of columns.
 * @return n-by-m matrix filled with 1.
 */
private static RealMatrix ones(int n, int m) {
    double[][] d = new double[n][m];
    for (int r = 0; r < n; r++) {
        Arrays.fill(d[r], 1.0);
    }
    return new Array2DRowRealMatrix(d, false);
}
 
Example 10
Source File: WhiteBox.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void checkIterationSanity(Queue q) {
    if (rnd.nextBoolean())
        return;
    int size = q.size();
    Object[] a = q.toArray();
    Object[] b = new Object[size+2];
    Arrays.fill(b, Boolean.TRUE);
    Object[] c = q.toArray(b);
    assertEquals(a.length, size);
    assertSame(b, c);
    assertNull(b[size]);
    assertSame(b[size+1], Boolean.TRUE);
    assertEquals(q.toString(), Arrays.toString(a));
    Integer[] xx = null, yy = null;
    if (size > 0) {
        xx = new Integer[size - 1];
        Arrays.fill(xx, 42);
        yy = ((Queue<Integer>)q).toArray(xx);
        for (Integer zz : xx)
            assertEquals(42, (int) zz);
    }
    Iterator it = q.iterator();
    for (int i = 0; i < size; i++) {
        if (rnd.nextBoolean()) assertTrue(it.hasNext());
        Object x = it.next();
        assertSame(x, a[i]);
        assertSame(x, b[i]);
        if (xx != null) assertSame(x, yy[i]);
    }
    if (rnd.nextBoolean()) assertTrue(!it.hasNext());
}
 
Example 11
Source File: ValueEncryptionUtilities.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This salts and encrypts a value and returns a base64 encoded version of the encrypted value.
 * @param value The value to be encrypted.
 * @param length The number on bytes to expand out to the source value to. This is so that all encryption
 *               operations generate the same length output. Watch out for multibyte characters as these will mean
 *               that your length must be more than the number of character in the string. If 0 then no padding is
 *               done.
 * @return A salted base64 encrypted version of the value.
 * @throws RuntimeException If encryption fails for any reason.
 */
public String encrypt(String value, int length) {
	try {
		byte[] salt = getSalt();
		SecretKey secret = getSecret(key, salt, getKeyLength());
		Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE);
		cipher.init(Cipher.ENCRYPT_MODE, secret);
		AlgorithmParameters params = cipher.getParameters();
		//get IV from cipher parameters
		IvParameterSpec parameterSpec = params.getParameterSpec(IvParameterSpec.class);
		// AES always has 128bit IV
		byte[] iv = parameterSpec.getIV();
		byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
		if (length != 0 && bytes.length > length) {
			throw new IllegalArgumentException("Can't encode as it's longer than our fixed length.");
		}
		int finalLength = (length == 0)?bytes.length: length;
		byte[] source = new byte[finalLength];
		System.arraycopy(bytes, 0, source, 0, bytes.length);
		// Fill the remainded of the array with illegal UTF-8 characters.
		Arrays.fill(source, bytes.length, source.length, (byte) UTF_8_ILLEGAL);
		byte[] ciphertext = cipher.doFinal(source);

		//create final array (in bytes) : IV + SALT + TEXT
		byte[] finalCiphertext = new byte[ciphertext.length+2*16];
		System.arraycopy(iv, 0, finalCiphertext, 0, 16);
		System.arraycopy(salt, 0, finalCiphertext, 16, 16);
		System.arraycopy(ciphertext, 0, finalCiphertext, 32, ciphertext.length);
		//encode all bytes in a Base64 string
		return encoder.encodeToString(finalCiphertext);
	} catch(Exception e){
		// We must not log out the value here so that the plaintext can't accidentally end up in the logs
		log.error("Error while encrypting.", e);
		return null;
	}
}
 
Example 12
Source File: SegmentedBuffer.java    From dict_build with Apache License 2.0 5 votes vote down vote up
private void _reset()
{
    // can we reuse the last (and thereby biggest) array for next time?
    if (_bufferedEntryCount > 0) {
        if (_bufferTail != null) {
            Object[] obs = _bufferTail.getData();
            // also, let's clear it of contents as well, just in case
            Arrays.fill(obs, null);
            _freeBuffer = obs;
        }
        // either way, must discard current contents
        _bufferHead = _bufferTail = null;
        _bufferedEntryCount = 0;
    }
}
 
Example 13
Source File: MergingMediaSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void releaseSourceInternal() {
  super.releaseSourceInternal();
  Arrays.fill(timelines, null);
  primaryManifest = null;
  periodCount = PERIOD_COUNT_UNSET;
  mergeError = null;
  pendingTimelineSources.clear();
  Collections.addAll(pendingTimelineSources, mediaSources);
}
 
Example 14
Source File: JmsMessageProducerTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 20000)
public void testSendMultipleMessagesNonPersistent() throws Exception {
    connection = createAmqpConnection();
    assertNotNull(connection);

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Queue queue = session.createQueue(name.getMethodName());
    MessageProducer producer = session.createProducer(queue);

    final int MSG_COUNT = 100;

    final QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
    assertEquals(0, proxy.getQueueSize());

    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

    byte[] payload = new byte[1024];
    Arrays.fill(payload, (byte) 255);

    for (int i = 0; i < MSG_COUNT; ++i) {
        BytesMessage message = session.createBytesMessage();
        message.writeBytes(payload);
        LOG.trace("sending message: {}", i);
        producer.send(message);
        LOG.trace("sent message: {}", i);
    }

    assertTrue("Should all make it to the Queue.", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return proxy.getQueueSize() == MSG_COUNT;
        }
    }));

    producer.close();
}
 
Example 15
Source File: EstimationUtils.java    From systemds with Apache License 2.0 4 votes vote down vote up
public static long getSparseProductOutputNnz(MatrixBlock m1, MatrixBlock m2) {
	if( !m1.isInSparseFormat() || !m2.isInSparseFormat() )
		throw new DMLRuntimeException("Invalid call to sparse output nnz estimation.");
	
	final int m = m1.getNumRows();
	final int n2 = m2.getNumColumns();
	long retNnz = 0;
	
	SparseBlock a = m1.getSparseBlock();
	SparseBlock b = m2.getSparseBlock();
	
	SparseRowVector tmpS = new SparseRowVector(1024);
	double[] tmpD = null;
		
	for( int i=0; i<m; i++ ) {
		if( a.isEmpty(i) ) continue;
		int alen = a.size(i);
		int apos = a.pos(i);
		int[] aix = a.indexes(i);
		double[] avals = a.values(i);
		
		//compute number of aggregated non-zeros for input row
		int nnz1 = (int) Math.min(UtilFunctions.computeNnz(b, aix, apos, alen), n2);
		boolean ldense = nnz1 > n2 / 128;
		
		//perform vector-matrix multiply w/ dense or sparse output
		if( ldense ) { //init dense tmp row
			tmpD = (tmpD == null) ? new double[n2] : tmpD;
			Arrays.fill(tmpD, 0);
		}
		else {
			tmpS.setSize(0);
		}
		for( int k=apos; k<apos+alen; k++ ) {
			if( b.isEmpty(aix[k]) ) continue;
			int blen = b.size(aix[k]);
			int bpos = b.pos(aix[k]);
			int[] bix = b.indexes(aix[k]);
			double aval = avals[k];
			double[] bvals = b.values(aix[k]);
			if( ldense ) { //dense aggregation
				for( int j=bpos; j<bpos+blen; j++ )
					tmpD[bix[j]] += aval * bvals[j];
			}
			else { //sparse aggregation
				for( int j=bpos; j<bpos+blen; j++ )
					tmpS.add(bix[j], aval * bvals[j]);
			}
		}
		retNnz += !ldense ? tmpS.size() :
			UtilFunctions.computeNnz(tmpD, 0, n2);
	}
	return retNnz;
}
 
Example 16
Source File: SynthTest.java    From ShizuruNotes with Apache License 2.0 4 votes vote down vote up
@Test
public void testStressReadDistanceExtraBits() {
  byte[] compressed = {
    (byte) 0x4f, (byte) 0xfe, (byte) 0xff, (byte) 0x3f, (byte) 0x00, (byte) 0x00, (byte) 0x00,
    (byte) 0x80, (byte) 0xe3, (byte) 0xb4, (byte) 0x0d, (byte) 0x00, (byte) 0x00, (byte) 0x07,
    (byte) 0x5b, (byte) 0x26, (byte) 0x31, (byte) 0x40, (byte) 0x02, (byte) 0x00, (byte) 0xe0,
    (byte) 0x4e, (byte) 0x9b, (byte) 0xf6, (byte) 0x69, (byte) 0xef, (byte) 0xff, (byte) 0x0c,
    (byte) 0x8d, (byte) 0x8c, (byte) 0x05, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00,
    (byte) 0x00, (byte) 0x00, (byte) 0x38, (byte) 0x4e, (byte) 0xdb, (byte) 0x00, (byte) 0x00,
    (byte) 0x70, (byte) 0xb0, (byte) 0x65, (byte) 0x12, (byte) 0x03, (byte) 0x24, (byte) 0xa8,
    (byte) 0xaa, (byte) 0xef, (byte) 0xab, (byte) 0xaa, (byte) 0x7f, (byte) 0x24, (byte) 0x16,
    (byte) 0x35, (byte) 0x8f, (byte) 0xac, (byte) 0x9e, (byte) 0x3d, (byte) 0xf7, (byte) 0xf3,
    (byte) 0xe3, (byte) 0x0a, (byte) 0xfc, (byte) 0xff, (byte) 0x03, (byte) 0x00, (byte) 0x00,
    (byte) 0x78, (byte) 0x01, (byte) 0x08, (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33,
    (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x41,
    (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46, (byte) 0x30, (byte) 0x31,
    (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37, (byte) 0x38,
    (byte) 0x39, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44, (byte) 0x45, (byte) 0x46,
    (byte) 0x30, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36,
    (byte) 0x37, (byte) 0x38, (byte) 0x39, (byte) 0x41, (byte) 0x42, (byte) 0x43, (byte) 0x44,
    (byte) 0x45, (byte) 0x46, (byte) 0x03
  };
  /* This line is added manually. */
  char[] stub = new char[8388602]; Arrays.fill(stub, 'c'); String hex = "0123456789ABCDEF";
  checkSynth(
  /*
   * main_header: 24
   * metablock_header_easy: 8388605, 0  // 2^23 - 3 = shortest 22-bit distance
   * command_easy: 8388602, "abc", 1
   * metablock_header_begin: 0, 0, 3, 0
   * vlq_blocktypes: 1  // num litetal block types
   * vlq_blocktypes: 1  // num command block types
   * vlq_blocktypes: 1  // num distance block types
   * ndirect: 0, 0
   * bits: "00"  // literal context modes
   * vlq_blocktypes: 1  // num literal Huffman trees
   * // command has no context -> num trees == num block types
   * vlq_blocktypes: 1  // num distance Huffman trees
   * huffman_fixed: 256
   * huffman_fixed: 704
   * // Begin of distance Huffman tree. First 15 codes have lengths 1 to 15.
   * // Symbol that corresponds to first half of 22-bit distance range is also
   * // 15. All other symbols are 0.
   * hskip: 0
   * clcl_ordered: 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4, 5,5,5,5
   * set_prefix_cl_rle: "0000", "0001", "0010", "0011", \
   *                    "0100", "0101", "0110", "0111", \
   *                    "1000", "1001", "1010", "1011", \
   *                    "1100", "1101", \
   *                    "11100", "11101", "11110", "11111"
   * cl_rle: 1
   * cl_rle: 2
   * cl_rle: 3
   * cl_rle: 4
   * cl_rle: 5
   * cl_rle: 6
   * cl_rle: 7
   * cl_rle: 8
   * cl_rle: 9
   * cl_rle: 10
   * cl_rle: 11
   * cl_rle: 12
   * cl_rle: 13
   * cl_rle: 14
   * cl_rle: 15
   * cl_rle_rep_0: 43
   * cl_rle: 15  // literal number 97, that is, the letter 'a'
   * // end of literal Huffman tree
   * command_inscopy_easy: 0, 3  // Insert 0, copy 3
   * // 15 bits of distance code plus 22 extra bits
   * command_dist_bits: "111111111111111", "0000000000000000000000"
   * metablock_uncompressed: "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
   * metablock_lastempty
   */
    compressed,
    true,
    /* This line is modified manually. */
    "abc" + new String(stub) + "abc" + hex + hex + hex
  );
}
 
Example 17
Source File: Sh1106.java    From androidthings-drivers with Apache License 2.0 4 votes vote down vote up
/**
 * Clears all pixel data in the display buffer. This will be rendered the next time
 * {@link #show()} is called.
 */
public void clearPixels() {
    for (byte[] row : mBuffer) {
        Arrays.fill(row, DATA_OFFSET, row.length, (byte) 0);
    }
}
 
Example 18
Source File: ArrayFieldVectorTest.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/** The whole vector is visited. */
@Test
public void testWalkInOptimizedOrderChangingVisitor1() {
    final Fraction[] data = new Fraction[] {
        Fraction.ZERO, Fraction.ONE, Fraction.ZERO,
        Fraction.ZERO, Fraction.TWO, Fraction.ZERO,
        Fraction.ZERO, Fraction.ZERO, new Fraction(3)
    };
    final ArrayFieldVector<Fraction> v = new ArrayFieldVector<Fraction>(data);
    final FieldVectorChangingVisitor<Fraction> visitor;
    visitor = new FieldVectorChangingVisitor<Fraction>() {
        private final boolean[] visited = new boolean[data.length];

        public Fraction visit(final int actualIndex, final Fraction actualValue) {
            visited[actualIndex] = true;
            Assert.assertEquals(Integer.toString(actualIndex),
                                data[actualIndex], actualValue);
            return actualValue.add(actualIndex);
        }

        public void start(final int actualSize, final int actualStart,
                          final int actualEnd) {
            Assert.assertEquals(data.length, actualSize);
            Assert.assertEquals(0, actualStart);
            Assert.assertEquals(data.length - 1, actualEnd);
            Arrays.fill(visited, false);
        }

        public Fraction end() {
            for (int i = 0; i < data.length; i++) {
                Assert.assertTrue("entry " + i + "has not been visited",
                                  visited[i]);
            }
            return Fraction.ZERO;
        }
    };
    v.walkInOptimizedOrder(visitor);
    for (int i = 0; i < data.length; i++) {
        Assert.assertEquals("entry " + i, data[i].add(i), v.getEntry(i));
    }
}
 
Example 19
Source File: VarCountingBloomFilter.java    From streaminer with Apache License 2.0 4 votes vote down vote up
/**
 * Clear the filter
 */
public void clear() {
    Arrays.fill(buckets, (byte)0);
    numNonZero = 0;
}
 
Example 20
Source File: BitArray.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
public final void setAll(){
    Arrays.fill(bits,0,lengthBytes,(byte)0xFF);
}