java.lang.Object
org.elasticsearch.common.util.BitArray
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.lucene.util.Accountable,Writeable,Releasable
public final class BitArray
extends Object
implements org.apache.lucene.util.Accountable, Releasable, Writeable
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionCreate the BitArray.BitArray(BigArrays bigArrays, boolean readOnly, StreamInput in) Create aBitArrayusingBigArrayswith bytes are written bywriteTo(org.elasticsearch.common.io.stream.StreamOutput) -
Method Summary
Modifier and TypeMethodDescriptionlongvoidclear(long index) Clear theindexth bit.voidclose()voidfill(long fromIndex, long toIndex, boolean value) Set or clear slots betweenfromIndexinclusive totoIndexbased onvalue.booleanget(long index) Is theindexth bit set?booleangetAndSet(long index) Set theindexth bit and returntrueif the bit was set already.longnextSetBit(long index) voidthis = this OR otherlongvoidset(long index) Set theindexth bit.voidset(long index, boolean value) Set or clear theindexth bit based on the specified value.longsize()voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Constructor Details
-
BitArray
Create the BitArray.- Parameters:
initialSize- the initial size of underlying storage expressed in bits.
-
BitArray
Create aBitArrayusingBigArrayswith bytes are written bywriteTo(org.elasticsearch.common.io.stream.StreamOutput)- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
set
public void set(long index, boolean value) Set or clear theindexth bit based on the specified value. -
set
public void set(long index) Set theindexth bit. -
getAndSet
public boolean getAndSet(long index) Set theindexth bit and returntrueif the bit was set already. -
or
this = this OR other -
nextSetBit
public long nextSetBit(long index) -
cardinality
public long cardinality() -
clear
public void clear(long index) Clear theindexth bit. -
get
public boolean get(long index) Is theindexth bit set? -
fill
public void fill(long fromIndex, long toIndex, boolean value) Set or clear slots betweenfromIndexinclusive totoIndexbased onvalue. -
size
public long size() -
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-