use of java.util.concurrent.atomic.AtomicLongArray in project intellij-community by JetBrains.
the class ConcurrentBitSet method getWord.
long getWord(int bitIndex) {
if (bitIndex < 0) {
throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex);
}
int arrayIndex = arrayIndex(bitIndex);
AtomicLongArray array = arrays.get(arrayIndex);
if (array == null) {
return 0;
}
int wordIndexInArray = wordIndexInArray(bitIndex);
return array.get(wordIndexInArray);
}
use of java.util.concurrent.atomic.AtomicLongArray in project intellij-community by JetBrains.
the class ConcurrentBitSet method hashCode.
/**
* Returns the hash code value for this bit set. The hash code depends
* only on which bits are set.
* <p/>
* <p>The hash code is defined to be the result of the following
* calculation:
* <pre> {@code
* public int hashCode() {
* long h = 1234;
* for (int i = words.length; --i >= 0; )
* h ^= words[i] * (i + 1);
* return (int)((h >> 32) ^ h);
* }}</pre>
* Note that the hash code changes if the set of bits is altered.
*
* @return the hash code value for this bit set
*/
@Override
public int hashCode() {
long h = 1234;
for (int a = 0; a < arrays.length(); a++) {
AtomicLongArray array = arrays.get(a);
if (array == null)
continue;
for (int i = 0; i < array.length(); i++) {
long word = array.get(i);
h ^= word * ((1 << a) + i);
}
}
return (int) (h >> 32 ^ h);
}
Aggregations