Package icyllis.modernui.text

# Class SpanSet<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
icyllis.modernui.text.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:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `int[]`
  `mSpanEnds`
  `int[]`
  `mSpanFlags`
  `int[]`
  `mSpanStarts`

  ### Fields inherited from class java.util.AbstractList

  `modCount`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SpanSet(Class<? extends E> type)`
  `SpanSet(Class<? extends E> type, boolean ignoreEmptySpans)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getNextTransition(int start, int limit)`
  Similar to `Spanned.nextSpanTransition(int, int, Class)`
  `boolean`
  `hasSpansIntersecting(int start, int end)`
  Returns true if there are spans intersecting the given interval.
  `boolean`
  `init(Spanned spanned, int start, int limit)`
  `void`
  `recycle()`
  Removes all internal references to the spans to avoid memory leaks.

  ### Methods inherited from class java.util.ArrayList

  `add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize`

  ### Methods inherited from class java.util.AbstractCollection

  `containsAll, toString`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.Collection

  `parallelStream, stream, toArray`

  ### Methods inherited from interface java.util.List

  `containsAll, reversed`

- ## 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)
    Similar to `Spanned.nextSpanTransition(int, int, Class)`

  - ### recycle

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