Class SequenceSet

  • All Implemented Interfaces:

    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.
    • Constructor Detail

      • SequenceSet

        public SequenceSet()
    • 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)
        value - the value to add to the list
        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.
        value - The value that should be removed from the SequenceSet.
        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.
        the first element from this list.
        NoSuchElementException - if this list is empty.
      • removeLastSequence

        public Sequence removeLastSequence()
        Removes and returns the last sequence from this list.
        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.
        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)
        all the id Sequences that are missing from this set that are not in between the range provided.
      • getReceived

        public List<Sequence> getReceived()
        all the Sequence that are in this list
      • contains

        public boolean contains​(long value)
        Returns true if the value given is contained within one of the sequences held in this set.
        value - The value to search for in the set.
        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.
        the total number of values contained in this set if it were to be iterated over like an array.