Search in sources :

Example 21 with AtomicLongArray

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);
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Example 22 with AtomicLongArray

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);
}
Also used : AtomicLongArray(java.util.concurrent.atomic.AtomicLongArray)

Aggregations

AtomicLongArray (java.util.concurrent.atomic.AtomicLongArray)22 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Random (java.util.Random)2 AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 GridRandom (org.apache.ignite.internal.util.GridRandom)2 NotNull (org.jetbrains.annotations.NotNull)2 Test (org.junit.Test)2 Deadline (scala.concurrent.duration.Deadline)2 ActorRef (akka.actor.ActorRef)1 ActorSystem (akka.actor.ActorSystem)1 JSONArray (com.alibaba.fastjson.JSONArray)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1