当前位置: 首页>>代码示例>>Java>>正文


Java AtomicLongArray.get方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicLongArray.get方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicLongArray.get方法的具体用法?Java AtomicLongArray.get怎么用?Java AtomicLongArray.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicLongArray的用法示例。


在下文中一共展示了AtomicLongArray.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType) throws IOException {
    SerializeWriter out = serializer.getWriter();
    if (object != null) {
        AtomicLongArray array = (AtomicLongArray) object;
        int len = array.length();
        out.append('[');
        for (int i = 0; i < len; i++) {
            long val = array.get(i);
            if (i != 0) {
                out.write(',');
            }
            out.writeLong(val);
        }
        out.append(']');
    } else if (out.isEnabled(SerializerFeature.WriteNullListAsEmpty)) {
        out.write("[]");
    } else {
        out.writeNull();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AtomicLongArrayCodec.java

示例2: write

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
    SerializeWriter out = serializer.getWriter();

    if (object == null) {
        if (out.isEnabled(SerializerFeature.WriteNullListAsEmpty)) {
            out.write("[]");
        } else {
            out.writeNull();
        }
        return;
    }

    AtomicLongArray array = (AtomicLongArray) object;
    int len = array.length();
    out.append('[');
    for (int i = 0; i < len; ++i) {
        long val = array.get(i);
        if (i != 0) {
            out.write(',');
        }
        out.writeLong(val);
    }
    out.append(']');
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:AtomicLongArrayCodec.java

示例3: set

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public void set(int position) {
    int segmentPosition = position >>> log2SegmentSize; /// which segment -- div by num bits per segment
    int longPosition = (position >>> 6) & segmentMask; /// which long in the segment -- remainder of div by num bits per segment
    int bitPosition = position & 0x3F; /// which bit in the long -- remainder of div by num bits in long (64)

    AtomicLongArray segment = getSegment(segmentPosition);

    long mask = 1L << bitPosition;

    // Thread safety: we need to loop until we win the race to set the long value.
    while(true) {
        // determine what the new long value will be after we set the appropriate bit.
        long currentLongValue = segment.get(longPosition);
        long newLongValue = currentLongValue | mask;

        // if no other thread has modified the value since we read it, we won the race and we are done.
        if(segment.compareAndSet(longPosition, currentLongValue, newLongValue))
            break;
    }
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:21,代码来源:ThreadSafeBitSet.java

示例4: clear

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public void clear(int position) {
    int segmentPosition = position >>> log2SegmentSize; /// which segment -- div by num bits per segment
    int longPosition = (position >>> 6) & segmentMask; /// which long in the segment -- remainder of div by num bits per segment
    int bitPosition = position & 0x3F; /// which bit in the long -- remainder of div by num bits in long (64)

    AtomicLongArray segment = getSegment(segmentPosition);

    long mask = ~(1L << bitPosition);

    // Thread safety: we need to loop until we win the race to set the long value.
    while(true) {
        // determine what the new long value will be after we set the appropriate bit.
        long currentLongValue = segment.get(longPosition);
        long newLongValue = currentLongValue & mask;

        // if no other thread has modified the value since we read it, we won the race and we are done.
        if(segment.compareAndSet(longPosition, currentLongValue, newLongValue))
            break;
    }
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:21,代码来源:ThreadSafeBitSet.java

示例5: maxSetBit

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public long maxSetBit() {
    ThreadSafeBitSetSegments segments = this.segments.get();

    int segmentIdx = segments.numSegments() - 1;

    for(;segmentIdx >= 0; segmentIdx--) {
        AtomicLongArray segment = segments.getSegment(segmentIdx);
        for(int longIdx=segment.length() - 1; longIdx >= 0; longIdx--) {
            long l = segment.get(longIdx);
            if(l != 0)
                return (segmentIdx << log2SegmentSize) + (longIdx * 64) + (63 - Long.numberOfLeadingZeros(l));
        }
    }

    return -1;
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:17,代码来源:ThreadSafeBitSet.java

示例6: changeWord

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
long changeWord(int bitIndex, @NotNull TLongFunction change) {
  if (bitIndex < 0) {
    throw new IndexOutOfBoundsException("bitIndex < 0: " + bitIndex);
  }

  AtomicLongArray array = getOrCreateArray(bitIndex);

  int wordIndexInArray = wordIndexInArray(bitIndex);
  long word;
  long newWord;
  do {
    word = array.get(wordIndexInArray);
    newWord = change.execute(word);
  }
  while (!array.compareAndSet(wordIndexInArray, word, newWord));
  return word;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConcurrentBitSet.java

示例7: equals

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/**
* Compares this object against the specified object.
* The result is {@code true} if and only if the argument is
* not {@code null} and is a {@code ConcurrentBitSet} object that has
* exactly the same set of bits set to {@code true} as this bit
* set. That is, for every nonnegative {@code int} index {@code k},
* <pre>((ConcurrentBitSet)obj).get(k) == this.get(k)</pre>
* must be true. The current sizes of the two bit sets are not compared.
*
* @param obj the object to compare with
* @return {@code true} if the objects are the same;
* {@code false} otherwise
* @see #size()
*/
@Override
public boolean equals(Object obj) {
  if (!(obj instanceof ConcurrentBitSet)) {
    return false;
  }
  if (this == obj) {
    return true;
  }

  ConcurrentBitSet set = (ConcurrentBitSet)obj;

  for (int i = 0; i < arrays.length(); i++) {
    AtomicLongArray array1 = arrays.get(i);
    AtomicLongArray array2 = set.arrays.get(i);
    if (array1 == null && array2 == null) continue;
    int size = array1 == null ? array2.length() : array1.length();
    for (int k=0; k<size;k++) {
      long word1 = array1 == null ? 0 : array1.get(k);
      long word2 = array2 == null ? 0 : array2.get(k);
      if (word1 != word2) return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:ConcurrentBitSet.java

示例8: toString

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/** Returns an {@link AtomicLongArray} array as a string, but does not print trailing zeroes.
 *
 * @param a an atomic array.
 * @return {@link Arrays#toString(long[])} of {@code a}, but without trailing zeroes.
 */
public static String toString(final AtomicLongArray a) {
	int i;
	for(i = a.length(); i-- != 0;) if (a.get(i) != 0) break;
	final long[] b = new long[i + 1];
	for(++i; i-- != 0;) b[i] = a.get(i);
	return Arrays.toString(b);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:13,代码来源:StatsThread.java

示例9: get

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public boolean get(int position) {
    int segmentPosition = position >>> log2SegmentSize; /// which segment -- div by num bits per segment
    int longPosition = (position >>> 6) & segmentMask; /// which long in the segment -- remainder of div by num bits per segment
    int bitPosition = position & 0x3F; /// which bit in the long -- remainder of div by num bits in long (64)

    AtomicLongArray segment = getSegment(segmentPosition);

    long mask = 1L << bitPosition;

    return ((segment.get(longPosition) & mask) != 0);
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:12,代码来源:ThreadSafeBitSet.java

示例10: nextSetBit

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public int nextSetBit(int fromIndex) {
    if (fromIndex < 0)
        throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);

    int segmentPosition = fromIndex >>> log2SegmentSize; /// which segment -- div by num bits per segment

    ThreadSafeBitSetSegments segments = this.segments.get();

    if(segmentPosition >= segments.numSegments())
        return -1;

    int longPosition = (fromIndex >>> 6) & segmentMask; /// which long in the segment -- remainder of div by num bits per segment
    int bitPosition = fromIndex & 0x3F; /// which bit in the long -- remainder of div by num bits in long (64)
    AtomicLongArray segment = segments.getSegment(segmentPosition);

    long word = segment.get(longPosition) & (0xffffffffffffffffL << bitPosition);

    while (true) {
        if (word != 0)
            return (segmentPosition << (log2SegmentSize)) + (longPosition << 6) + Long.numberOfTrailingZeros(word);
        if (++longPosition > segmentMask) {
            segmentPosition++;
            if(segmentPosition >= segments.numSegments())
                return -1;
            segment = segments.getSegment(segmentPosition);
            longPosition = 0;
        }

        word = segment.get(longPosition);
    }
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:32,代码来源:ThreadSafeBitSet.java

示例11: populateNewHashArray

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/**
 * Hash all of the existing values specified by the keys in the supplied long array
 * into the supplied AtomicLongArray.
 */
private void populateNewHashArray(AtomicLongArray newKeys, long[] valuesToAdd) {
    int modBitmask = newKeys.length() - 1;

    for(int i=0;i<valuesToAdd.length;i++) {
        if(valuesToAdd[i] != EMPTY_BUCKET_VALUE) {
            int hash = rehashPreviouslyAddedData(valuesToAdd[i]);
            int bucket = hash & modBitmask;
            while(newKeys.get(bucket) != EMPTY_BUCKET_VALUE)
                bucket = (bucket + 1) & modBitmask;
            newKeys.set(bucket, valuesToAdd[i]);
        }
    }
}
 
开发者ID:Netflix,项目名称:hollow,代码行数:18,代码来源:ByteArrayOrdinalMap.java

示例12: _incDouble

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
@Override
protected final void _incDouble(int offset, double delta) {
  final AtomicLongArray doubleStorage = this.doubleStorage;
  while (true) {
    final long longValue = doubleStorage.get(offset);
    final long newValue = Double.doubleToLongBits(Double
        .longBitsToDouble(longValue) + delta);
    if (doubleStorage.compareAndSet(offset, longValue, newValue)) {
      return;
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:13,代码来源:Atomic60StatisticsImpl.java

示例13: standardDeviationHistogram

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
public static final double standardDeviationHistogram(AtomicLongArray histogram){
	long sum=max(1, sum(histogram));
	long sum2=0;
	for(int i=0; i<histogram.length(); i++){
		sum2+=(histogram.get(i)*i);
	}
	double avg=sum2/(double)sum;
	double sumdev2=0;
	for(int i=0; i<histogram.length(); i++){
		double dev=avg-i;
		double dev2=dev*dev;
		sumdev2+=(histogram.get(i)*dev2);
	}
	return Math.sqrt(sumdev2/sum);
}
 
开发者ID:abiswas-odu,项目名称:Disco,代码行数:16,代码来源:Tools.java

示例14: andCount

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/**
 * @param kmers Read kmers
 * @param counts Cluster kmer counts
 * @return Score
 */
static final float andCount(int[] kmers, AtomicLongArray counts){
	int sum=0;
	for(int i=0; i<kmers.length; i++){
		int kmer=kmers[i];
		long count=counts.get(kmer);
		if(count>0){sum++;}
	}
	return sum/(float)kmers.length;
}
 
开发者ID:abiswas-odu,项目名称:Disco,代码行数:15,代码来源:ClusterTools.java

示例15: getWord

import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ConcurrentBitSet.java


注:本文中的java.util.concurrent.atomic.AtomicLongArray.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。