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 int[] startIndices
    • Constructor Detail

      • SegmentOffsetTree

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

      • build

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

        public int endOffset​(int pos)
      • getStartIndex

        public int getStartIndex​(int pos)
      • findSegmentPosByOffset

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

        @Nullable
        public Segment findSegmentByOffset​(int offset,
                                           @NotNull
                                           BasedSequence baseSeq,
                                           @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
      • addSegments

        @Deprecated
        public void addSegments​(@NotNull
                                IBasedSegmentBuilder<?> builder,
                                @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
                                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