Class SegmentOffsetTree


  • public class SegmentOffsetTree
    extends SegmentTree
    Segment tree which uses offsets instead of aggregated length of segments

    Used to find original base offsets in SegmentedSequence result

    NOTE: although it is a SegmentTree, most of the SegmentTree functions use index into sequence for context and cannot be used with offset data. Their use will throw IllegalStateException if invoked.

    • Field Detail

      • startIndices

        @NotNull
        protected final @org.jetbrains.annotations.NotNull int[] startIndices
    • Constructor Detail

      • SegmentOffsetTree

        protected SegmentOffsetTree​(@NotNull
                                    @org.jetbrains.annotations.NotNull int[] treeData,
                                    @NotNull
                                    @org.jetbrains.annotations.NotNull byte[] segmentBytes,
                                    @NotNull
                                    @org.jetbrains.annotations.NotNull int[] startIndices)
    • Method Detail

      • build

        @NotNull
        public static @NotNull SegmentOffsetTree build​(@NotNull
                                                       @NotNull java.lang.Iterable<Seg> segments,
                                                       @NotNull
                                                       @NotNull java.lang.CharSequence allText)
      • endOffset

        public int endOffset​(int pos)
      • getStartIndex

        public int getStartIndex​(int pos)
      • findSegmentPosByOffset

        @Nullable
        public @Nullable SegmentTreePos findSegmentPosByOffset​(int offset)
      • getPreviousText

        @Nullable
        public @Nullable Segment getPreviousText​(@NotNull
                                                 @NotNull Segment segment,
                                                 @NotNull
                                                 @NotNull BasedSequence baseSeq)
      • getNextText

        @Nullable
        public @Nullable Segment getNextText​(@NotNull
                                             @NotNull Segment segment,
                                             @NotNull
                                             @NotNull BasedSequence baseSeq)
      • findSegmentByOffset

        @Nullable
        public @Nullable Segment findSegmentByOffset​(int offset,
                                                     @NotNull
                                                     @NotNull BasedSequence baseSeq,
                                                     @Nullable
                                                     @Nullable Segment hint)
      • hasPreviousAnchor

        @Deprecated
        public boolean hasPreviousAnchor​(int pos)
        Deprecated.
        Overrides:
        hasPreviousAnchor in class SegmentTree
      • aggrLength

        @Deprecated
        public int aggrLength​(int pos)
        Deprecated.
        Overrides:
        aggrLength in class SegmentTree
      • findSegment

        @Deprecated
        @Nullable
        public @Nullable Segment findSegment​(int index,
                                             int startPos,
                                             int endPos,
                                             @NotNull
                                             @NotNull BasedSequence baseSeq,
                                             @Nullable
                                             @Nullable Segment hint)
        Deprecated.
        Overrides:
        findSegment in class SegmentTree
      • addSegments

        @Deprecated
        public void addSegments​(@NotNull
                                @NotNull IBasedSegmentBuilder<?> builder,
                                @NotNull
                                @NotNull SegmentTreeRange treeRange)
        Deprecated.
        Description copied from class: SegmentTree
        Add segments selected by given treeRange
        Overrides:
        addSegments in class SegmentTree
        Parameters:
        builder - based segment builder
        treeRange - treeRange for which to add segments
      • addSegments

        @Deprecated
        public void addSegments​(@NotNull
                                @NotNull IBasedSegmentBuilder<?> builder,
                                int startIndex,
                                int endIndex,
                                int startOffset,
                                int endOffset,
                                int startPos,
                                int endPos)
        Deprecated.
        Description copied from class: SegmentTree
        Add segments of subsequence of this tree to builder
        Overrides:
        addSegments in class SegmentTree
        Parameters:
        builder - builder to which to add the segments
        startIndex - start index of sub-sequence of segment tree
        endIndex - end index of sub-sequence of segment tree
        startOffset - start offset of the subsequence to use as start anchor
        endOffset - end offset of the subsequence to use as end anchor
        startPos - start pos of sub-sequence segments in tree
        endPos - end pos of sub-sequence segments in tree