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>
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)
. Also retrieves
spanStart, spanEnd, spanFlags simultaneously with constant complexity.
- Fields are public for a convenient direct access (read only).
- Empty spans are ignored by default.
- Cannot be used as normal ArrayList (you can only consume this object after init).
- See Also:
-
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getNextTransition
(int start, int limit) Similar toSpanned.nextSpanTransition(int, int, Class)
int
getSpanEnd
(int index) int
getSpanFlags
(int index) int
getSpanStart
(int index) boolean
hasSpansIntersecting
(int start, int end) Returns true if there are spans intersecting the given interval.boolean
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
-
spanStarts
public int[] spanStarts -
spanEnds
public int[] spanEnds -
spanFlags
public int[] spanFlags
-
-
Constructor Details
-
SpanSet
-
SpanSet
-
-
Method Details
-
init
- Returns:
- true if non-empty
-
getSpanStart
public int getSpanStart(int index) -
getSpanEnd
public int getSpanEnd(int index) -
getSpanFlags
public int getSpanFlags(int index) -
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 toSpanned.nextSpanTransition(int, int, Class)
-
recycle
public void recycle()Removes all internal references to the spans to avoid memory leaks.
-