Package org.jgroups.util
Class SeqnoList
java.lang.Object
org.jgroups.util.FixedSizeBitSet
org.jgroups.util.SeqnoList
- All Implemented Interfaces:
Iterable<Long>,Constructable<SeqnoList>,SizeStreamable,Streamable
public class SeqnoList
extends FixedSizeBitSet
implements SizeStreamable, Iterable<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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.jgroups.util.FixedSizeBitSet
ADDRESS_BITS_PER_WORD, BITS_PER_WORD, size, WORD_MASK, words -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(long seqno) Adds a single seqnoadd(long... seqnos) add(long from, long to) Adds a seqno rangeadd(Collection<Long> seqnos) create()Creates an instance of the class implementing this interfacelonggetFirst()Returns the first seqno, this is also the lowest seqno in the list as we add seqnos in orderlonggetLast()Returns the last seqno, this is also the highest seqno in the list as we add seqnos in orderprotected intindex(long seqno) booleanisEmpty()iterator()voidRead the state of the current object (including superclasses) from instream Note that the input stream must not be closedremoveHigherThan(long seqno) Removes all seqnos > seqnoremoveLowerThan(long seqno) Removes all seqnos > seqnoprotected longseqno(int index) intReturns the size (in bytes) of the marshalled objectintsize()toString()Returns a string representation of this bit set.voidwriteTo(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, wordIndexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
offset
protected long offset
-
-
Constructor Details
-
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 Details
-
create
Description copied from interface:ConstructableCreates an instance of the class implementing this interface- Specified by:
createin interfaceConstructable<SeqnoList>
-
add
Adds a single seqno -
add
-
add
-
add
Adds a seqno range -
removeHigherThan
Removes all seqnos > seqno -
removeLowerThan
Removes all seqnos > seqno -
getLast
public long getLast()Returns the last seqno, this is also the highest seqno in the list as we add seqnos in order -
getFirst
public long getFirst()Returns the first seqno, this is also the lowest seqno in the list as we add seqnos in order -
serializedSize
public int serializedSize()Description copied from interface:SizeStreamableReturns the size (in bytes) of the marshalled object- Specified by:
serializedSizein interfaceSizeStreamable
-
writeTo
Description 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:
IOException
-
readFrom
Description 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:
IOException
-
size
public int size()- Overrides:
sizein classFixedSizeBitSet
-
isEmpty
public boolean isEmpty() -
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
-
index
protected int index(long seqno) -
seqno
protected long seqno(int index)
-