org.jgroups.util
Class SeqnoList

java.lang.Object
  extended by org.jgroups.util.SeqnoList
All Implemented Interfaces:
java.lang.Iterable<java.lang.Long>, Streamable

public class SeqnoList
extends java.lang.Object
implements Streamable, java.lang.Iterable<java.lang.Long>

A list of sequence numbers (seqnos). Seqnos have to be added in ascending order, and can be single seqnos or seqno ranges (e.g. [5-10]). This class is unsynchronized. Note that for serialization, we assume that the lowest and highest seqno in the list are not more than 2 ^ 31 apart.

Since:
3.1
Author:
Bela Ban

Nested Class Summary
protected static class SeqnoList.Seqno
           
protected  class SeqnoList.SeqnoListIterator
           
protected static class SeqnoList.SeqnoRange
           
 
Field Summary
protected  java.util.List<SeqnoList.Seqno> seqnos
           
 
Constructor Summary
SeqnoList()
           
SeqnoList(long seqno)
           
SeqnoList(long from, long to)
           
 
Method Summary
 SeqnoList add(long... seqnos)
           
 SeqnoList add(long seqno)
          Adds a single seqno
 SeqnoList add(long from, long to)
          Adds a seqno range
 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
 java.util.Iterator<java.lang.Long> iterator()
           
 void readFrom(java.io.DataInput in)
          Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
 void remove(long min_seqno)
          Removes all seqnos <= seqno
 void removeHigherThan(long max_seqno)
          Removes all seqnos > seqno
 int serializedSize()
           
 int size()
           
 java.lang.String toString()
           
 void writeTo(java.io.DataOutput out)
          Write the entire state of the current object (including superclasses) to outstream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

seqnos

protected final java.util.List<SeqnoList.Seqno> seqnos
Constructor Detail

SeqnoList

public SeqnoList()

SeqnoList

public SeqnoList(long seqno)

SeqnoList

public SeqnoList(long from,
                 long to)
Method Detail

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


remove

public void remove(long min_seqno)
Removes all seqnos <= seqno


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:

writeTo

public void writeTo(java.io.DataOutput out)
             throws java.lang.Exception
Description copied from interface: Streamable
Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed

Specified by:
writeTo in interface Streamable
Throws:
java.lang.Exception

readFrom

public void readFrom(java.io.DataInput in)
              throws java.lang.Exception
Description copied from interface: Streamable
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed

Specified by:
readFrom in interface Streamable
Throws:
java.lang.Exception

serializedSize

public int serializedSize()

size

public int size()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

iterator

public java.util.Iterator<java.lang.Long> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Long>


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.