Package com.openhtmltopdf.util
Class DescendantBoxSpliterator
- java.lang.Object
-
- com.openhtmltopdf.util.DescendantBoxSpliterator
-
- All Implemented Interfaces:
java.util.Spliterator<Box>
public class DescendantBoxSpliterator extends java.lang.Object implements java.util.Spliterator<Box>
A spliterator that can be used to create a stream of descendant boxes in breadth first order.
NOTE: This is likely slower than simply creating a box list recursively for small number of descendants but gets relatively faster (and uses less memory) as the list of descendants increases in size.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDescendantBoxSpliterator.State-
Nested classes/interfaces inherited from interface java.util.Spliterator
java.util.Spliterator.OfDouble, java.util.Spliterator.OfInt, java.util.Spliterator.OfLong, java.util.Spliterator.OfPrimitive<T extends java.lang.Object,T_CONS extends java.lang.Object,T_SPLITR extends java.util.Spliterator.OfPrimitive<T,T_CONS,T_SPLITR>>
-
-
Field Summary
Fields Modifier and Type Field Description private intchildIndexprivate DescendantBoxSpliterator.StatecurStateprivate java.util.Deque<Box>unprocessed
-
Constructor Summary
Constructors Constructor Description DescendantBoxSpliterator(Box parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidadd(Box bx)intcharacteristics()private Boxcurrent()longestimateSize()private BoxgetNext()private BoxgetNextInlineChild(java.util.List<? extends java.lang.Object> inlineChilds)private booleanhasChildren(Box bx)private booleanhasNext()private voidnext()private voidsetState(DescendantBoxSpliterator.State newState)booleantryAdvance(java.util.function.Consumer<? super Box> action)java.util.Spliterator<Box>trySplit()
-
-
-
Field Detail
-
unprocessed
private final java.util.Deque<Box> unprocessed
-
curState
private DescendantBoxSpliterator.State curState
-
childIndex
private int childIndex
-
-
Constructor Detail
-
DescendantBoxSpliterator
public DescendantBoxSpliterator(Box parent)
-
-
Method Detail
-
hasChildren
private boolean hasChildren(Box bx)
-
add
private void add(Box bx)
-
next
private void next()
-
hasNext
private boolean hasNext()
-
current
private Box current()
-
setState
private void setState(DescendantBoxSpliterator.State newState)
-
getNext
private Box getNext()
-
getNextInlineChild
private Box getNextInlineChild(java.util.List<? extends java.lang.Object> inlineChilds)
-
tryAdvance
public boolean tryAdvance(java.util.function.Consumer<? super Box> action)
- Specified by:
tryAdvancein interfacejava.util.Spliterator<Box>
-
trySplit
public java.util.Spliterator<Box> trySplit()
- Specified by:
trySplitin interfacejava.util.Spliterator<Box>
-
estimateSize
public long estimateSize()
- Specified by:
estimateSizein interfacejava.util.Spliterator<Box>
-
characteristics
public int characteristics()
- Specified by:
characteristicsin interfacejava.util.Spliterator<Box>
-
-