Package org.jgroups.util
Class SeqnoList
- java.lang.Object
-
- org.jgroups.util.FixedSizeBitSet
-
- org.jgroups.util.SeqnoList
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Long>,Constructable<SeqnoList>,SizeStreamable,Streamable
public class SeqnoList extends FixedSizeBitSet implements SizeStreamable, java.lang.Iterable<java.lang.Long>, Constructable<SeqnoList>
A bitset of missing messages with a fixed size. The index (in the bit set) of a seqno is computed as seqno - offset.- Since:
- 3.1
- Author:
- Bela Ban
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classSeqnoList.SeqnoListIterator
-
Field Summary
Fields Modifier and Type Field Description protected longoffset-
Fields inherited from class org.jgroups.util.FixedSizeBitSet
ADDRESS_BITS_PER_WORD, BITS_PER_WORD, size, WORD_MASK, words
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SeqnoListadd(long seqno)Adds a single seqnoSeqnoListadd(long... seqnos)SeqnoListadd(long from, long to)Adds a seqno rangejava.util.function.Supplier<? extends SeqnoList>create()Creates an instance of the class implementing this interfacelonggetLast()Returns the last seqno, this should also be the highest seqno in the list as we're supposed to add seqnos in orderprotected intindex(long seqno)booleanisEmpty()java.util.Iterator<java.lang.Long>iterator()voidreadFrom(java.io.DataInput in)Read the state of the current object (including superclasses) from instream Note that the input stream must not be closedvoidremoveHigherThan(long max_seqno)Removes all seqnos > seqnoprotected longseqno(int index)intserializedSize()Returns the size (in bytes) of the marshalled objectintsize()java.lang.StringtoString()Returns a string representation of this bit set.voidwriteTo(java.io.DataOutput out)Write the entire state of the current object (including superclasses) to outstream.-
Methods inherited from class org.jgroups.util.FixedSizeBitSet
cardinality, clear, clear, flip, get, nextClearBit, nextSetBit, previousSetBit, set, set, wordIndex
-
-
-
-
Constructor Detail
-
SeqnoList
public SeqnoList()
Only to be used by serialization
-
SeqnoList
public SeqnoList(int size, long offset)Creates a SeqnoList with a capacity for size elements.- Parameters:
size- The max number of seqnos in the bitsetoffset- Lowest seqno. Used to compute the index of a given seqno into the bitset: seqno - offset
-
SeqnoList
public SeqnoList(int size)
-
-
Method Detail
-
create
public java.util.function.Supplier<? extends SeqnoList> create()
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<SeqnoList>
-
add
public SeqnoList add(long seqno)
Adds a single seqno
-
add
public SeqnoList add(long... seqnos)
-
add
public SeqnoList add(long from, long to)
Adds a seqno range
-
removeHigherThan
public void removeHigherThan(long max_seqno)
Removes all seqnos > seqno
-
getLast
public long getLast()
Returns the last seqno, this should also be the highest seqno in the list as we're supposed to add seqnos in order- Returns:
-
serializedSize
public int serializedSize()
Description copied from interface:SizeStreamableReturns the size (in bytes) of the marshalled object- Specified by:
serializedSizein interfaceSizeStreamable
-
writeTo
public void writeTo(java.io.DataOutput out) throws java.io.IOExceptionDescription copied from interface:StreamableWrite the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed- Specified by:
writeToin interfaceStreamable- Throws:
java.io.IOException
-
readFrom
public void readFrom(java.io.DataInput in) throws java.io.IOExceptionDescription copied from interface:StreamableRead the state of the current object (including superclasses) from instream Note that the input stream must not be closed- Specified by:
readFromin interfaceStreamable- Throws:
java.io.IOException
-
size
public int size()
- Overrides:
sizein classFixedSizeBitSet
-
isEmpty
public boolean isEmpty()
-
toString
public java.lang.String toString()
Description copied from class:FixedSizeBitSetReturns a string representation of this bit set. For every index for which thisBitSetcontains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.Overrides the
toStringmethod ofObject.Example:
BitSet drPepper = new BitSet();
NowdrPepper.toString()returns "{}".drPepper.set(2);
NowdrPepper.toString()returns "{2}".drPepper.set(4); drPepper.set(10);
NowdrPepper.toString()returns "{2, 4, 10}".- Overrides:
toStringin classFixedSizeBitSet- Returns:
- a string representation of this bit set.
-
iterator
public java.util.Iterator<java.lang.Long> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.lang.Long>
-
index
protected int index(long seqno)
-
seqno
protected long seqno(int index)
-
-