Class SegmentedSequenceFull

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

public final class SegmentedSequenceFull 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

    • nonBaseChars

      private final boolean nonBaseChars
    • baseOffsets

      private final int[] baseOffsets
    • baseStartOffset

      private final int baseStartOffset
  • Constructor Details

    • SegmentedSequenceFull

      private SegmentedSequenceFull(BasedSequence baseSeq, int startOffset, int endOffset, int length, boolean nonBaseChars, int[] baseOffsets, int baseStartOffset)
  • Method Details

    • 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
    • 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 SegmentedSequenceFull create(@NotNull @NotNull BasedSequence baseSequence, ISegmentBuilder<?> builder)
      Base Constructor
      Parameters:
      baseSequence - base sequence for segmented sequence
      builder - builder for which to construct segmented sequence
      Returns:
      segmented sequence
    • subSequence

      private SegmentedSequenceFull subSequence(BasedSequence baseSeq, int[] baseOffsets, int baseStartOffset, boolean nonBaseChars, int length)
    • of

      @Deprecated public static BasedSequence of(BasedSequence basedSequence, @NotNull @NotNull Iterable<? extends BasedSequence> segments)
      Deprecated.
      use BasedSequence.getBuilder() and then ISequenceBuilder.addAll(Iterable) or if you know which are based segments vs. out of base Strings then use BasedSegmentBuilder to construct segments directly. If you must use segments then use SegmentedSequence.create(BasedSequence, Iterable) which does the builder calls for you.
      Parameters:
      basedSequence - base sequence for the segments
      segments - list of based sequences to put into a based sequence
      Returns:
      based sequence of segments. Result is a sequence which looks like all the segments were concatenated, while still maintaining the original offset for each character when using getIndexOffset(int)(int index)
    • of

      @Deprecated public static BasedSequence of(BasedSequence... segments)
      Deprecated.