Here you can find the source of fillArrayAND(final short[] container, final long[] bitmap1, final long[] bitmap2)
Parameter | Description |
---|---|
container | where we write |
bitmap1 | first bitmap |
bitmap2 | second bitmap |
public static void fillArrayAND(final short[] container, final long[] bitmap1, final long[] bitmap2)
//package com.java2s; /*//from www .j a v a 2s . c om * (c) the authors Licensed under the Apache License, Version 2.0. */ public class Main { /** * Compute the bitwise AND between two long arrays and write the set bits in the container. * * @param container where we write * @param bitmap1 first bitmap * @param bitmap2 second bitmap */ public static void fillArrayAND(final short[] container, final long[] bitmap1, final long[] bitmap2) { int pos = 0; if (bitmap1.length != bitmap2.length) { throw new IllegalArgumentException("not supported"); } for (int k = 0; k < bitmap1.length; ++k) { long bitset = bitmap1[k] & bitmap2[k]; while (bitset != 0) { long t = bitset & -bitset; container[pos++] = (short) (k * 64 + Long.bitCount(t - 1)); bitset ^= t; } } } }