Class SegmentedSequenceTree

All Implemented Interfaces:
BasedOptionsHolder, BasedSequence, IRichSequence<BasedSequence>, ReplacedBasedSequence, SequenceUtils, CharSequence, Comparable<CharSequence>

public final class SegmentedSequenceTree extends SegmentedSequence
A BasedSequence which consists of segments of other BasedSequences NOTE: very efficient for random access but extremely wasteful with space by allocating 4 bytes per character in the sequence with corresponding construction penalty use SegmentedSequenceTree which is binary tree based segmented sequence with minimal overhead and optimized to give penalty free random access for most applications.
  • Field Details

  • Constructor Details

    • SegmentedSequenceTree

      private SegmentedSequenceTree(BasedSequence baseSeq, int startOffset, int endOffset, int length, @NotNull @NotNull SegmentTree segmentTree)
    • SegmentedSequenceTree

      private SegmentedSequenceTree(BasedSequence baseSeq, @NotNull @NotNull SegmentTree segmentTree, @NotNull @NotNull SegmentTreeRange subSequenceRange)
  • Method Details

    • getCache

      @NotNull private @NotNull SegmentedSequenceTree.Cache getCache(int index)
    • getCachedSegment

      @Nullable private @Nullable Segment getCachedSegment()
    • getIndexOffset

      public int getIndexOffset(int index)
      Description copied from interface: BasedSequence
      Get the offset of index in this sequence mapped to offset into BasedSequence.getBaseSequence() and BasedSequence.getBase() original text source. NOTE: if the character at given index does not equal the corresponding character in the base sequence then this method should return -1 otherwise segmented based sequence will be created for original base character
      Parameters:
      index - index for which to get the offset in original source
      Returns:
      offset of index of this sequence in original text
    • addSegments

      public void addSegments(@NotNull @NotNull IBasedSegmentBuilder<?> builder)
      Description copied from interface: BasedSequence
      Add segments for this sequence, replacing out of base characters with strings
      Specified by:
      addSegments in interface BasedSequence
      Overrides:
      addSegments in class BasedSequenceImpl
      Parameters:
      builder - builder
    • getSegmentTree

      @NotNull public @NotNull SegmentTree getSegmentTree()
      Description copied from class: BasedSequenceImpl
      Get the segment tree for this sequence or null if sequence is contiguous from startOffset to endOffset
      Specified by:
      getSegmentTree in interface BasedSequence
      Overrides:
      getSegmentTree in class BasedSequenceImpl
      Returns:
      null for contiguous sequences, else segment tree for this sequence
    • charAt

      public char charAt(int index)
    • subSequence

      @NotNull public @NotNull BasedSequence subSequence(int startIndex, int endIndex)
      Description copied from interface: BasedSequence
      Get a portion of this sequence
      Parameters:
      startIndex - offset from startIndex of this sequence
      endIndex - offset from startIndex of this sequence
      Returns:
      based sequence which represents the requested range of this sequence.
    • create

      public static SegmentedSequenceTree create(@NotNull @NotNull BasedSequence baseSeq, ISegmentBuilder<?> builder)
      Base Constructor
      Parameters:
      baseSeq - base sequence
      builder - builder containing segments for this sequence
      Returns:
      segmented sequence