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 class
DescendantBoxSpliterator.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 int
childIndex
private DescendantBoxSpliterator.State
curState
private 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 void
add(Box bx)
int
characteristics()
private Box
current()
long
estimateSize()
private Box
getNext()
private Box
getNextInlineChild(java.util.List<? extends java.lang.Object> inlineChilds)
private boolean
hasChildren(Box bx)
private boolean
hasNext()
private void
next()
private void
setState(DescendantBoxSpliterator.State newState)
boolean
tryAdvance(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:
tryAdvance
in interfacejava.util.Spliterator<Box>
-
trySplit
public java.util.Spliterator<Box> trySplit()
- Specified by:
trySplit
in interfacejava.util.Spliterator<Box>
-
estimateSize
public long estimateSize()
- Specified by:
estimateSize
in interfacejava.util.Spliterator<Box>
-
characteristics
public int characteristics()
- Specified by:
characteristics
in interfacejava.util.Spliterator<Box>
-
-