Class SequenceSet
- java.lang.Object
-
- org.apache.activemq.store.kahadb.disk.util.LinkedNodeList<Sequence>
-
- org.apache.activemq.store.kahadb.disk.util.SequenceSet
-
public class SequenceSet extends LinkedNodeList<Sequence> implements Iterable<Long>
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
Nested Classes Modifier and Type Class Description static classSequenceSet.Marshaller
-
Constructor Summary
Constructors Constructor Description SequenceSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(long value)voidadd(Sequence value)booleancontains(int first, int last)booleancontains(long value)Returns true if the value given is contained within one of the sequences held in this set.Sequenceget(int value)List<Sequence>getMissing(long first, long last)List<Sequence>getReceived()Iterator<Long>iterator()voidmerge(SequenceSet sequenceSet)longrangeSize()Computes the size of this Sequence by summing the values of all the contained sequences.booleanremove(long value)Removes the given value from the Sequence set, splitting a contained sequence if necessary.voidremove(Sequence value)voidremove(SequenceSet sequenceSet)longremoveFirst()Removes and returns the first element from this list.SequenceremoveFirstSequence(long count)Removes and returns the first sequence that is count range large.SequenceremoveLastSequence()Removes and returns the last sequence from this list.-
Methods inherited from class org.apache.activemq.store.kahadb.disk.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
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
add
public void add(Sequence value)
-
merge
public void merge(SequenceSet sequenceSet)
-
remove
public void remove(SequenceSet sequenceSet)
-
remove
public void remove(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.
-
remove
public boolean remove(long value)
Removes the given value from the Sequence set, splitting a contained sequence if necessary.- Parameters:
value- The value that should be removed from the SequenceSet.- Returns:
- true if the value was removed from the set, false if there was no sequence in the set that contained the given value.
-
removeFirst
public long removeFirst()
Removes and returns the first element from this list.- Returns:
- the first element from this list.
- Throws:
NoSuchElementException- if this list is empty.
-
removeLastSequence
public Sequence removeLastSequence()
Removes and returns the last sequence from this list.- Returns:
- the last sequence from this list or null if the list is empty.
-
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 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.
-
contains
public boolean contains(long value)
Returns true if the value given is contained within one of the sequences held in this set.- Parameters:
value- The value to search for in the set.- Returns:
- true if the value is contained in the set.
-
contains
public boolean contains(int first, int last)
-
get
public Sequence get(int value)
-
rangeSize
public long rangeSize()
Computes the size of this Sequence by summing the values of all the contained sequences.- Returns:
- the total number of values contained in this set if it were to be iterated over like an array.
-
-