本文整理了Java中java.util.BitSet.toLongArray()
方法的一些代码示例,展示了BitSet.toLongArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.toLongArray()
方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:toLongArray
[英]Returns a new long[] containing a little-endian representation of the bits of this BitSet, suitable for passing to valueOf to reconstruct this BitSet.
[中]返回一个新的long[],其中包含此位集位的小endian表示形式,适合传递给valueOf以重建此位集。
代码示例来源:origin: apache/ignite
/**
* Returns long array representation of connection row for given node {@code idx}.
*
* @param idx Node index.
* @return Long array connection row representation.
*/
private long[] connectionRow(int idx) {
if (cachedConnRows[idx] != null)
return cachedConnRows[idx];
return cachedConnRows[idx] = connections[idx].toLongArray();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void writeBitSet(BitSet val) {
writeLongArray(val != null ? val.toLongArray() : null);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void writeBitSet(BitSet val) {
writeLongArray(val != null ? val.toLongArray() : null);
}
代码示例来源:origin: RoaringBitmap/RoaringBitmap
/**
* Generate a MutableRoaringBitmap out of a BitSet
*
* @param bitSet original bitset (will not be modified)
* @return roaring bitmap equivalent to BitSet
*/
public static MutableRoaringBitmap bitmapOf(final BitSet bitSet) {
return bitmapOf(bitSet.toLongArray());
}
代码示例来源:origin: RoaringBitmap/RoaringBitmap
/**
* Generate a RoaringBitmap out of a BitSet
*
* @param bitSet original bitset (will not be modified)
* @return roaring bitmap equivalent to BitSet
*/
public static RoaringBitmap bitmapOf(final BitSet bitSet) {
return bitmapOf(bitSet.toLongArray());
}
代码示例来源:origin: RuedigerMoeller/fast-serialization
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo,
FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
out.writeObject(((BitSet)toWrite).toLongArray());
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public String toString(BitSet value) {
StringBuilder builder = new StringBuilder();
for ( long token : value.toLongArray() ) {
if ( builder.length() > 0 ) {
builder.append( DELIMITER );
}
builder.append( Long.toString( token, 2 ) );
}
return builder.toString();
}
代码示例来源:origin: apache/hive
public String toString() {
String batchSizeString = "batchSize " + Integer.toString(batchSize);
if (bitSet != null) {
long bitMask = bitSet.toLongArray()[0];
batchSizeString += " repeating 0x" + Long.toHexString(bitMask);
}
boolean selectedInUse = (selected != null);
batchSizeString += " selectedInUse " + selectedInUse;
if (selectedInUse) {
batchSizeString += " selected " + Arrays.toString(selected);
}
return batchSizeString;
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Object deepCopy(Object value)
throws HibernateException {
return value == null ? null :
BitSet.valueOf( BitSet.class.cast( value ).toLongArray() );
}
代码示例来源:origin: stackoverflow.com
import java.util.BitSet;
class Scratch {
public static void main(String[] args) {
BitSet bits1 = fromString("1000001");
BitSet bits2 = fromString("1111111");
System.out.println(toString(bits1)); // prints 1000001
System.out.println(toString(bits2)); // prints 1111111
bits2.and(bits1);
System.out.println(toString(bits2)); // prints 1000001
}
private static BitSet fromString(final String s) {
return BitSet.valueOf(new long[] { Long.parseLong(s, 2) });
}
private static String toString(BitSet bs) {
return Long.toString(bs.toLongArray()[0], 2);
}
}
代码示例来源:origin: vsch/flexmark-java
public long[] toLongArray() {return myBits.toLongArray();}
代码示例来源:origin: stackoverflow.com
int n = 12345;
BitSet bs = BitSet.valueOf(new long[]{n});
long l = bs.toLongArray()[0];
代码示例来源:origin: vsch/flexmark-java
public int cardinality(int start, int end) {
int count = 0;
if (start >= 0 && end > 0 && start < end) {
int firstBit = myBits.nextSetBit(0);
int lastBit = myBits.previousSetBit(myBits.length()) + 1;
if (start < firstBit) start = firstBit;
if (end > lastBit) end = lastBit;
if (start <= end && myBits.length() > 0) {
int startIndex = start >> 6;
int endIndex = end >> 6;
long startMask = -1L << (start & 63); // 0-FF, 1-FE, 2-FC, 3-FE, 4-F0....
long endMask = ~(-1L << (end & 63)); // 0-0, 1-01, 2-03, 3-07
if (endMask == 0) {
endIndex--;
endMask = -1L;
}
long[] words = myBits.toLongArray();
for (int i = startIndex; i <= endIndex; i++) {
long word = words[i];
if (i == startIndex) word &= startMask;
if (i == endIndex) word &= endMask;
count += Long.bitCount(word);
}
}
}
return count;
}
代码示例来源:origin: Netflix/hollow
public void reservePreviouslyPopulatedOrdinals(BitSet populatedOrdinals) {
unusedPreviousOrdinals = BitSet.valueOf(populatedOrdinals.toLongArray());
recalculateFreeOrdinals(populatedOrdinals);
}
代码示例来源:origin: Netflix/hollow
/**
* Exclude any objects which are referenced by excluded objects.
*/
public void excludeReferencedObjects() {
Set<HollowReadStateEngine> stateEngines = new HashSet<HollowReadStateEngine>();
for(Map.Entry<HollowTypeReadState, BitSet> entry : excludedOrdinals.entrySet())
stateEngines.add(entry.getKey().getStateEngine());
for(HollowReadStateEngine stateEngine : stateEngines) {
Map<String, BitSet> typeBitSetsForStateEngine = new HashMap<String, BitSet>();
for(Map.Entry<HollowTypeReadState, BitSet> entry : excludedOrdinals.entrySet()) {
if(entry.getKey().getStateEngine() == stateEngine) {
String type = entry.getKey().getSchema().getName();
typeBitSetsForStateEngine.put(type, BitSet.valueOf(entry.getValue().toLongArray()));
}
}
TransitiveSetTraverser.addTransitiveMatches(stateEngine, typeBitSetsForStateEngine);
for(Map.Entry<String, BitSet> entry : typeBitSetsForStateEngine.entrySet())
excludedOrdinals.put(stateEngine.getTypeState(entry.getKey()), entry.getValue());
}
}
代码示例来源:origin: apache/phoenix
@Override
public void write(DataOutput output) throws IOException {
WritableUtils.writeCompressedByteArray(output, this.emptyCFName);
long[] longArrayOfBitSet = trackedColumns.toLongArray();
WritableUtils.writeVInt(output, longArrayOfBitSet.length);
for (Long l : longArrayOfBitSet) {
WritableUtils.writeVLong(output, l);
}
WritableUtils.writeVInt(output, encodingScheme.ordinal());
WritableUtils.writeVInt(output, this.conditionOnlyCfs.size());
for (byte[] f : this.conditionOnlyCfs) {
WritableUtils.writeCompressedByteArray(output, f);
}
}
代码示例来源:origin: io.github.myui/hivemall-core
@Override
public List<LongWritable> terminatePartial(AggregationBuffer aggr) throws HiveException {
ArrayAggregationBuffer agg = (ArrayAggregationBuffer) aggr;
long[] array = agg.bitset.toLongArray();
if (agg.bitset == null || agg.bitset.isEmpty()) {
return null;
}
return WritableUtils.toWritableList(array);
}
代码示例来源:origin: net.openhft/affinity
public static String toBinaryString(BitSet set) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(out);
final long[] longs = set.toLongArray();
for (long aLong : longs) {
writer.write(Long.toBinaryString(aLong));
}
writer.flush();
return new String(out.toByteArray(), java.nio.charset.StandardCharsets.UTF_8);
}
}
代码示例来源:origin: org.apache.hivemall/hivemall-core
@Override
public List<LongWritable> terminate(@SuppressWarnings("deprecation") AggregationBuffer aggr)
throws HiveException {
ArrayAggregationBuffer agg = (ArrayAggregationBuffer) aggr;
long[] longs = agg.bitset.toLongArray();
return WritableUtils.toWritableList(longs);
}
}
代码示例来源:origin: io.github.myui/hivemall-core
@Override
public List<LongWritable> terminate(AggregationBuffer aggr) throws HiveException {
ArrayAggregationBuffer agg = (ArrayAggregationBuffer) aggr;
long[] longs = agg.bitset.toLongArray();
return WritableUtils.toWritableList(longs);
}
}
内容来源于网络,如有侵权,请联系作者删除!