org.apache.kahadb.util
Class SequenceSet

java.lang.Object
  extended by org.apache.kahadb.util.LinkedNodeList<Sequence>
      extended by org.apache.kahadb.util.SequenceSet

public class SequenceSet
extends LinkedNodeList<Sequence>

Keeps track of a added long values. Collapses ranges of numbers using a Sequence representation. Use to keep track of received message ids to find out if a message is duplicate or if there are any missing messages.

Author:
chirino

Nested Class Summary
static class SequenceSet.Marshaller
           
 
Constructor Summary
SequenceSet()
           
 
Method Summary
 boolean add(long value)
           
 void add(Sequence value)
           
 boolean contains(int first, int last)
           
 java.util.List<Sequence> getMissing(long first, long last)
           
 java.util.List<Sequence> getReceived()
           
 long removeFirst()
          Removes and returns the first element from this list.
 Sequence removeFirstSequence(long count)
          Removes and returns the first sequence that is count range large.
 Sequence removeLastSequence()
           
 
Methods inherited from class org.apache.kahadb.util.LinkedNodeList
addFirst, addFirst, addLast, addLast, clear, getHead, getTail, isEmpty, reparent, rotate, rotateTo, size, toArrayList, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequenceSet

public SequenceSet()
Method Detail

add

public void add(Sequence value)

add

public boolean add(long value)
Parameters:
value - the value to add to the list
Returns:
false if the value was a duplicate.

removeFirst

public long removeFirst()
Removes and returns the first element from this list.

Returns:
the first element from this list.
Throws:
java.util.NoSuchElementException - if this list is empty.

removeLastSequence

public Sequence removeLastSequence()

removeFirstSequence

public Sequence removeFirstSequence(long count)
Removes and returns the first sequence that is count range large.

Returns:
a sequence that is count range large, or null if no sequence is that large in the list.

getMissing

public java.util.List<Sequence> getMissing(long first,
                                           long last)
Returns:
all the id Sequences that are missing from this set that are not in between the range provided.

getReceived

public java.util.List<Sequence> getReceived()
Returns:
all the Sequence that are in this list

contains

public boolean contains(int first,
                        int last)


Copyright © 2005-2012. All Rights Reserved.