Class SpanSet<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>

public class SpanSet<E> extends ArrayList<E>
A cached set of spans. Caches the result of Spanned.getSpans(int, int, Class, java.util.List) and then provides faster access to Spanned.nextSpanTransition(int, int, Class).

Fields are public for a convenient direct access (read only).

Note that empty spans are ignored by this class by default.

See Also:
  • Field Details

    • mSpanStarts

      public int[] mSpanStarts
    • mSpanEnds

      public int[] mSpanEnds
    • mSpanFlags

      public int[] mSpanFlags
  • Constructor Details

    • SpanSet

      public SpanSet(@NonNull Class<? extends E> type)
    • SpanSet

      public SpanSet(@NonNull Class<? extends E> type, boolean ignoreEmptySpans)
  • Method Details

    • init

      public boolean init(@NonNull Spanned spanned, int start, int limit)
      Returns:
      true if non-empty
    • hasSpansIntersecting

      public boolean hasSpansIntersecting(int start, int end)
      Returns true if there are spans intersecting the given interval.
      Parameters:
      end - must be strictly greater than start
    • getNextTransition

      public int getNextTransition(int start, int limit)
    • recycle

      public void recycle()
      Removes all internal references to the spans to avoid memory leaks.